-
Notifications
You must be signed in to change notification settings - Fork 2
/
table_test.go
41 lines (35 loc) · 1 KB
/
table_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
package sol
import "testing"
// All schemas are declared in sol_test.go
func TestTable(t *testing.T) {
if users.name != "users" {
t.Errorf("Unexpected table name: %s != users", users.name)
}
// Confirm the fields created by Modifiers
if len(users.pk) != 1 {
t.Fatalf("Unexpected length of primary keys: %d != 1", len(users.pk))
}
if users.pk[0] != "id" {
t.Errorf("Unexpected primary key: %s != id", users.pk[0])
}
if len(users.uniques) != 1 {
t.Fatalf("Unexpected length of uniques: %d != 1", len(users.uniques))
}
if len(users.uniques[0]) != 1 {
t.Fatalf(
"Unexpected length of unique array: %d != 1",
len(users.uniques),
)
}
if users.uniques[0][0] != "email" {
t.Errorf("Unexpected unique: %s != email", users.uniques[0][0])
}
}
func TestTable_Select(t *testing.T) {
expect := NewTester(t, defaultDialect{})
// Select statements without destination structs
expect.SQL(
users.Select(),
`SELECT users.id, users.email, users.name, users.password, users.created_at FROM users`,
)
}