-
-
Notifications
You must be signed in to change notification settings - Fork 243
/
migration_info_test.go
73 lines (62 loc) · 1.18 KB
/
migration_info_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
package pop
import (
"sort"
"testing"
"github.com/stretchr/testify/assert"
)
func TestSortingMigrations(t *testing.T) {
examples := Migrations{
{
Version: "1",
DBType: "all",
},
{
Version: "1",
DBType: "postgres",
},
{
Version: "2",
DBType: "cockroach",
},
{
Version: "2",
DBType: "all",
},
{
Version: "3",
DBType: "all",
},
{
Version: "3",
DBType: "mysql",
},
}
t.Run("case=enforces precedence for specific up migrations", func(t *testing.T) {
migrations := make(Migrations, len(examples))
copy(migrations, examples)
expectedOrder := Migrations{
examples[1],
examples[0],
examples[2],
examples[3],
examples[5],
examples[4],
}
sort.Sort(UpMigrations{migrations})
assert.Equal(t, expectedOrder, migrations)
})
t.Run("case=enforces precedence for specific down migrations", func(t *testing.T) {
migrations := make(Migrations, len(examples))
copy(migrations, examples)
expectedOrder := Migrations{
examples[5],
examples[4],
examples[2],
examples[3],
examples[1],
examples[0],
}
sort.Sort(DownMigrations{migrations})
assert.Equal(t, expectedOrder, migrations)
})
}