forked from go-rel/rel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
column_test.go
97 lines (88 loc) · 1.64 KB
/
column_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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package rel
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestCreateColumn(t *testing.T) {
var (
options = []ColumnOption{
Unique(true),
Required(true),
Unsigned(true),
Primary(true),
Limit(1000),
Precision(5),
Scale(2),
Default(0),
Options("options"),
}
column = createColumn("add", Decimal, options)
)
assert.Equal(t, Column{
Name: "add",
Type: Decimal,
Unique: true,
Required: true,
Unsigned: true,
Primary: true,
Limit: 1000,
Precision: 5,
Scale: 2,
Default: 0,
Options: "options",
}, column)
}
func TestRenameColumn(t *testing.T) {
var (
options = []ColumnOption{
Required(true),
Unsigned(true),
Limit(1000),
Precision(5),
Scale(2),
Default(0),
Options("options"),
}
column = renameColumn("add", "rename", options)
)
assert.Equal(t, Column{
Op: SchemaRename,
Name: "add",
Rename: "rename",
Required: true,
Unsigned: true,
Limit: 1000,
Precision: 5,
Scale: 2,
Default: 0,
Options: "options",
}, column)
}
func TestDropColumn(t *testing.T) {
var (
options = []ColumnOption{
Required(true),
Unsigned(true),
Limit(1000),
Precision(5),
Scale(2),
Default(0),
Options("options"),
}
column = dropColumn("drop", options)
)
assert.Equal(t, Column{
Op: SchemaDrop,
Name: "drop",
Required: true,
Unsigned: true,
Limit: 1000,
Precision: 5,
Scale: 2,
Default: 0,
Options: "options",
}, column)
}
func TestColumn_InternalTableDefinition(t *testing.T) {
assert.NotPanics(t, func() { Column{}.internalTableDefinition() })
}