forked from gobuffalo/pop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
match_test.go
76 lines (63 loc) · 2.03 KB
/
match_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
package pop
import (
"github.com/stretchr/testify/require"
"testing"
)
func Test_ParseMigrationFilenameFizzDown(t *testing.T) {
r := require.New(t)
m, err := ParseMigrationFilename("20190611004000_create_providers.down.fizz")
r.NoError(err)
r.NotNil(m)
r.Equal(m.Version, "20190611004000")
r.Equal(m.Name, "create_providers")
r.Equal(m.DBType, "all")
r.Equal(m.Direction, "down")
r.Equal(m.Type, "fizz")
}
func Test_ParseMigrationFilenameFizzUp(t *testing.T) {
r := require.New(t)
m, err := ParseMigrationFilename("20190611004000_create_providers.up.fizz")
r.NoError(err)
r.NotNil(m)
r.Equal(m.Version, "20190611004000")
r.Equal(m.Name, "create_providers")
r.Equal(m.DBType, "all")
r.Equal(m.Direction, "up")
r.Equal(m.Type, "fizz")
}
func Test_ParseMigrationFilenameFizzUpPostgres(t *testing.T) {
r := require.New(t)
m, err := ParseMigrationFilename("20190611004000_create_providers.pg.up.fizz")
r.NotNil(err)
r.Equal(err.Error(), "invalid database type \"postgres\", expected \"all\" because fizz is database type independent")
r.Nil(m)
}
func Test_ParseMigrationFilenameFizzDownPostgres(t *testing.T) {
r := require.New(t)
m, err := ParseMigrationFilename("20190611004000_create_providers.pg.down.fizz")
r.NotNil(err)
r.Equal(err.Error(), "invalid database type \"postgres\", expected \"all\" because fizz is database type independent")
r.Nil(m)
}
func Test_ParseMigrationFilenameSQLUp(t *testing.T) {
r := require.New(t)
m, err := ParseMigrationFilename("20190611004000_create_providers.up.sql")
r.NoError(err)
r.NotNil(m)
r.Equal(m.Version, "20190611004000")
r.Equal(m.Name, "create_providers")
r.Equal(m.DBType, "all")
r.Equal(m.Direction, "up")
r.Equal(m.Type, "sql")
}
func Test_ParseMigrationFilenameSQLUpPostgres(t *testing.T) {
r := require.New(t)
m, err := ParseMigrationFilename("20190611004000_create_providers.pg.up.sql")
r.NoError(err)
r.NotNil(m)
r.Equal(m.Version, "20190611004000")
r.Equal(m.Name, "create_providers")
r.Equal(m.DBType, "postgres")
r.Equal(m.Direction, "up")
r.Equal(m.Type, "sql")
}