-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdbtable_test.go
44 lines (38 loc) · 1.15 KB
/
dbtable_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package structdbpostgres
import (
"testing"
)
type TableTestStruct struct {
ID int64 `json:"db_table_struct_id"`
Flags int64 `json:"db_table_struct_flags"`
}
// TestCreateTables tests if CreateTables creates tables in the database
func TestCreateTables(t *testing.T) {
st := &TableTestStruct{}
err := testController.CreateTables(st)
if err != nil {
t.Fatalf("CreateTables failed to create table for a struct: %s", err.Error())
}
cnt, err2 := getTableNameCnt("struct2db_table_test_structs")
if err2 != nil {
t.Fatalf("CreateTables failed to create table for a struct: %s", err2.Error())
}
if cnt == 0 {
t.Fatalf("CreateTables failed to create the table")
}
}
// TestDropTables tests if DropTables drops tables in the database
func TestDropTables(t *testing.T) {
st := &TableTestStruct{}
err := testController.DropTables(st)
if err != nil {
t.Fatalf("DropTables failed to drop table for a struct: %s", err.Error())
}
cnt, err2 := getTableNameCnt("struct2db_table_test_structs")
if err2 != nil {
t.Fatalf("DropTables failed to drop table for a struct: %s", err2.Error())
}
if cnt != 0 {
t.Fatalf("DropTables failed to drop the table")
}
}