forked from pressly/goose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
up_test.go
35 lines (33 loc) · 808 Bytes
/
up_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
package goose
import (
"testing"
)
func TestFindMissingMigrations(t *testing.T) {
known := Migrations{
{Version: 1},
{Version: 3},
{Version: 4},
{Version: 5},
{Version: 7}, // <-- database max version_id
}
new := Migrations{
{Version: 1},
{Version: 2}, // missing migration
{Version: 3},
{Version: 4},
{Version: 5},
{Version: 6}, // missing migration
{Version: 7}, // <-- database max version_id
{Version: 8}, // new migration
}
got := findMissingMigrations(known, new, 7)
if len(got) != 2 {
t.Fatalf("invalid migration count: got:%d want:%d", len(got), 2)
}
if got[0].Version != 2 {
t.Errorf("expecting first migration: got:%d want:%d", got[0].Version, 2)
}
if got[1].Version != 6 {
t.Errorf("expecting second migration: got:%d want:%d", got[0].Version, 6)
}
}