-
Notifications
You must be signed in to change notification settings - Fork 0
/
adapter_test.go
58 lines (56 loc) · 1.48 KB
/
adapter_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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package migrate
import "testing"
func TestTableAdapterFuncs(t *testing.T) {
tests := []struct {
Name string
Func func(log LogFunc) *TableAdapter
Expected TableAdapter
}{
{
Name: "MySQL",
Func: NewMySQLAdapter,
Expected: TableAdapter{
CreateTableOptions: " ENGINE=InnoDB DEFAULT CHARSET=utf8mb4",
PlaceholderVersion: "?",
PlaceholderUpgrade: "?",
PlaceholderComment: "?",
},
},
{
Name: "PostgreSQL",
Func: NewPostgreSQLAdapter,
Expected: TableAdapter{
PlaceholderVersion: "$1",
PlaceholderUpgrade: "$2",
PlaceholderComment: "$3",
},
},
{
Name: "SQLite",
Func: NewSQLiteAdapter,
Expected: TableAdapter{
PlaceholderVersion: "?",
PlaceholderUpgrade: "?",
PlaceholderComment: "?",
},
},
}
for _, tt := range tests {
t.Run(tt.Name, func(t *testing.T) {
a := tt.Func(t.Logf)
if a == nil {
t.Error("adapter unexpectedly nil")
return
}
if a.CreateTableOptions != tt.Expected.CreateTableOptions {
t.Errorf("expected CreateTableOptions to be %q, got %q", tt.Expected.CreateTableOptions, a.CreateTableOptions)
}
if a.PlaceholderVersion != tt.Expected.PlaceholderVersion {
t.Errorf("expected PlaceholderVersion to be %q, got %q", tt.Expected.PlaceholderVersion, a.PlaceholderVersion)
}
if a.PlaceholderComment != tt.Expected.PlaceholderComment {
t.Errorf("expected PlaceholderComment to be %q, got %q", tt.Expected.PlaceholderComment, a.PlaceholderComment)
}
})
}
}