forked from gsamokovarov/gloat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
source_test.go
52 lines (37 loc) · 1.3 KB
/
source_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
package gloat
import (
"io/ioutil"
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
)
func TestFileSystemSourceCollect(t *testing.T) {
td := "testdata/migrations"
fs := NewFileSystemSource(td)
migrations, err := fs.Collect()
assert.Nil(t, err)
m1, err := MigrationFromBytes(filepath.Join(td, "20170329154959_introduce_domain_model"), ioutil.ReadFile)
assert.Nil(t, err)
m2, err := MigrationFromBytes(filepath.Join(td, "20170511172647_irreversible_migration_brah"), ioutil.ReadFile)
assert.Nil(t, err)
m3, err := MigrationFromBytes(filepath.Join(td, "20180905150724_concurrent_migration"), ioutil.ReadFile)
assert.Nil(t, err)
m4, err := MigrationFromBytes(filepath.Join(td, "20180920181906_migration_with_an_error"), ioutil.ReadFile)
assert.Nil(t, err)
expectedMigrations := Migrations{m1, m2, m3, m4}
assert.Equal(t, migrations, expectedMigrations)
}
func TestFileSystemSourceCollectEmpty(t *testing.T) {
td := "testdata/no_migrations"
fs := NewFileSystemSource(td)
migrations, err := fs.Collect()
assert.Nil(t, err)
assert.Len(t, migrations, 0)
}
func TestAssetSourceDoesNotBreakOnIrreversibleMigrations(t *testing.T) {
td := "testdata/migrations"
fs := NewAssetSource(td, Asset, AssetDir)
migrations, err := fs.Collect()
assert.Nil(t, err)
assert.Len(t, migrations, 4)
}