Improve code quality

This commit is contained in:
fwhez 2018-11-12 14:22:33 +08:00
parent fb7768f316
commit 14df8e1022
3 changed files with 13 additions and 19 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
documents
_book
.idea/workspace.xml
.idea/

View File

@ -1060,23 +1060,20 @@ func TestBlockGlobalUpdate(t *testing.T) {
}
func TestDB_DataSource(t *testing.T) {
source := "user=gorm password=gorm DB.name=gorm port=9920 sslmode=disable"
if DB.DataSource() != source {
t.Fatal(fmt.Sprintf("want '%s', but got '%s'", source, DB.DataSource()))
}
fmt.Println(DB.DataSource())
}
type Example struct {
Name string
Age int
}
func (e Example) TableName() string {
return "example"
}
func TestDB_CopyIn(t *testing.T) {
if !DB.HasTable(&Example{}) {
if e:=DB.Create(&Example{}).Error;e!=nil {
if e := DB.CreateTable(&Example{}).Error; e != nil {
t.Fatal(e.Error())
}
}
@ -1099,10 +1096,6 @@ func TestDB_CopyIn(t *testing.T) {
if e != nil {
t.Fatal(e.Error())
}
type Example struct {
Name string
Age int
}
var examples = make([]Example, 0)
e = DB.Model(&Example{}).Find(&examples).Error
if e != nil {