forked from larapulse/migrator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema_test.go
81 lines (55 loc) · 1.43 KB
/
schema_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
package migrator
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestSchemaCreateTable(t *testing.T) {
assert := assert.New(t)
s := Schema{}
assert.Len(s.pool, 0)
tb := Table{Name: "test"}
s.CreateTable(tb)
assert.Len(s.pool, 1)
assert.Equal(createTableCommand{tb}, s.pool[0])
}
func TestSchemaDropTable(t *testing.T) {
assert := assert.New(t)
s := Schema{}
assert.Len(s.pool, 0)
s.DropTable("test", false, "")
assert.Len(s.pool, 1)
assert.Equal(dropTableCommand{"test", false, ""}, s.pool[0])
}
func TestSchemaDropTableIfExists(t *testing.T) {
assert := assert.New(t)
s := Schema{}
assert.Len(s.pool, 0)
s.DropTableIfExists("test")
assert.Len(s.pool, 1)
assert.Equal(dropTableCommand{"test", true, ""}, s.pool[0])
}
func TestSchemaRenameTable(t *testing.T) {
assert := assert.New(t)
s := Schema{}
assert.Len(s.pool, 0)
s.RenameTable("from", "to")
assert.Len(s.pool, 1)
assert.Equal(renameTableCommand{"from", "to"}, s.pool[0])
}
func TestSchemaAlterTable(t *testing.T) {
assert := assert.New(t)
s := Schema{}
assert.Len(s.pool, 0)
s.AlterTable("table", TableCommands{})
assert.Len(s.pool, 1)
assert.Equal(alterTableCommand{"table", TableCommands{}}, s.pool[0])
}
func TestSchemaCustomCommand(t *testing.T) {
assert := assert.New(t)
c := testDummyCommand("DROP PROCEDURE abc")
s := Schema{}
assert.Len(s.pool, 0)
s.CustomCommand(c)
assert.Len(s.pool, 1)
assert.Equal(c, s.pool[0])
}