-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
columns_test.go
71 lines (59 loc) · 1.44 KB
/
columns_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
67
68
69
70
71
package fizz_test
import (
"testing"
"github.com/gobuffalo/fizz"
"github.com/stretchr/testify/require"
)
func Test_Column_Stringer(t *testing.T) {
t.Run("primary column", func(tt *testing.T) {
r := require.New(tt)
c := fizz.Column{
Name: "pk",
ColType: "int",
Primary: true,
}
r.Equal(`t.Column("pk", "int", {primary: true})`, c.String())
})
t.Run("primary column with raw default", func(tt *testing.T) {
r := require.New(tt)
c := fizz.Column{
Name: "pk",
ColType: "int",
Primary: true,
Options: map[string]interface{}{
"default_raw": "uuid_generate_v4()",
},
}
r.Equal(`t.Column("pk", "int", {default_raw: "uuid_generate_v4()", primary: true})`, c.String())
})
t.Run("simple column", func(tt *testing.T) {
r := require.New(tt)
c := fizz.Column{
Name: "name",
ColType: "string",
}
r.Equal(`t.Column("name", "string")`, c.String())
})
t.Run("with option", func(tt *testing.T) {
r := require.New(tt)
c := fizz.Column{
Name: "alive",
ColType: "boolean",
Options: map[string]interface{}{
"null": true,
},
}
r.Equal(`t.Column("alive", "boolean", {null: true})`, c.String())
})
t.Run("with string option", func(tt *testing.T) {
r := require.New(tt)
c := fizz.Column{
Name: "price",
ColType: "numeric",
Options: map[string]interface{}{
"default": "1.00",
},
}
r.Equal(`t.Column("price", "numeric", {default: "1.00"})`, c.String())
})
}