Add clean-up for testcase TestDB_CopyIn

This commit is contained in:
fwhez 2018-11-12 10:43:55 +08:00
parent 432181e1f0
commit 8355eb2fc2

View File

@ -1067,7 +1067,17 @@ func TestDB_DataSource(t *testing.T) {
}
func TestDB_CopyIn(t *testing.T) {
DB.Exec("create table if not exists example(name varchar, age integer)")
e:=DB.Exec("create table if not exists example(name varchar, age integer)").Error
defer func(){
er := DB.Exec("drop table if exists example").Error
if er != nil {
t.Fatal(e.Error())
}
}()
if e != nil {
t.Fatal(e.Error())
}
defer DB.Exec("drop table")
var args = make([][]interface{}, 0)
args = append(args, []interface{}{
"tom", 9,
@ -1076,7 +1086,7 @@ func TestDB_CopyIn(t *testing.T) {
}, []interface{}{
"jim", 11,
})
e := DB.CopyIn(true, "example", args, "name", "age")
e = DB.CopyIn(true, "example", args, "name", "age")
if e != nil {
t.Fatal(e.Error())
}