forked from eaigner/jet
-
Notifications
You must be signed in to change notification settings - Fork 1
/
suite_test.go
42 lines (38 loc) · 950 Bytes
/
suite_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
package jet
import (
"reflect"
"testing"
)
func TestBuildList(t *testing.T) {
var s Suite
s.AddSQL("U1", "D1")
s.AddSQL("U2", "D2")
s.AddSQL("U3", "D3")
s.AddSQL("U4", "D4")
// Test up
if l := s.buildList(true, 0); !reflect.DeepEqual(l, s.Migrations) {
t.Fatal(l)
}
if l := s.buildList(true, 1); !reflect.DeepEqual(l, s.Migrations[1:]) {
t.Fatal(l)
}
if l := s.buildList(true, 4); !reflect.DeepEqual(l, s.Migrations[4:]) {
t.Fatal(l)
}
if l := s.buildList(true, 5); !reflect.DeepEqual(l, s.Migrations[4:]) {
t.Fatal(l)
}
// Test down
if l := s.buildList(false, 0); !reflect.DeepEqual(l, []*Migration{}) {
t.Fatal(l)
}
if l := s.buildList(false, 1); !reflect.DeepEqual(l, reverse(s.Migrations[:1])) {
t.Fatal(l)
}
if l := s.buildList(false, 4); !reflect.DeepEqual(l, reverse(s.Migrations[:4])) {
t.Fatal(l)
}
if l := s.buildList(false, 5); !reflect.DeepEqual(l, reverse(s.Migrations[:4])) {
t.Fatal(l)
}
}