-
Notifications
You must be signed in to change notification settings - Fork 553
/
Copy pathkeys_test.go
66 lines (55 loc) · 1.21 KB
/
keys_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
59
60
61
62
63
64
65
66
package drivers
import "testing"
func TestSQLColDefinitions(t *testing.T) {
t.Parallel()
cols := []Column{
{Name: "one", Type: "int64"},
{Name: "two", Type: "string"},
{Name: "three", Type: "string"},
}
defs := SQLColDefinitions(cols, []string{"one"})
if len(defs) != 1 {
t.Error("wrong number of defs:", len(defs))
}
if got := defs[0].String(); got != "one int64" {
t.Error("wrong def:", got)
}
defs = SQLColDefinitions(cols, []string{"one", "three"})
if len(defs) != 2 {
t.Error("wrong number of defs:", len(defs))
}
if got := defs[0].String(); got != "one int64" {
t.Error("wrong def:", got)
}
if got := defs[1].String(); got != "three string" {
t.Error("wrong def:", got)
}
}
func TestTypes(t *testing.T) {
t.Parallel()
defs := SQLColumnDefs{
{Type: "thing1"},
{Type: "thing2"},
}
ret := defs.Types()
if ret[0] != "thing1" {
t.Error("wrong type:", ret[0])
}
if ret[1] != "thing2" {
t.Error("wrong type:", ret[1])
}
}
func TestNames(t *testing.T) {
t.Parallel()
defs := SQLColumnDefs{
{Name: "thing1"},
{Name: "thing2"},
}
ret := defs.Names()
if ret[0] != "thing1" {
t.Error("wrong type:", ret[0])
}
if ret[1] != "thing2" {
t.Error("wrong type:", ret[1])
}
}