forked from golang-migrate/migrate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
storage_test.go
37 lines (34 loc) · 1.66 KB
/
storage_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
package googlecloudstorage
import (
"testing"
"github.com/fsouza/fake-gcs-server/fakestorage"
"github.com/golang-migrate/migrate/v4/source"
st "github.com/golang-migrate/migrate/v4/source/testing"
)
func Test(t *testing.T) {
server := fakestorage.NewServer([]fakestorage.Object{
{BucketName: "some-bucket", Name: "staging/migrations/1_foobar.up.sql", Content: []byte("1 up")},
{BucketName: "some-bucket", Name: "staging/migrations/1_foobar.down.sql", Content: []byte("1 down")},
{BucketName: "some-bucket", Name: "prod/migrations/1_foobar.up.sql", Content: []byte("1 up")},
{BucketName: "some-bucket", Name: "prod/migrations/1_foobar.down.sql", Content: []byte("1 down")},
{BucketName: "some-bucket", Name: "prod/migrations/3_foobar.up.sql", Content: []byte("3 up")},
{BucketName: "some-bucket", Name: "prod/migrations/4_foobar.up.sql", Content: []byte("4 up")},
{BucketName: "some-bucket", Name: "prod/migrations/4_foobar.down.sql", Content: []byte("4 down")},
{BucketName: "some-bucket", Name: "prod/migrations/5_foobar.down.sql", Content: []byte("5 down")},
{BucketName: "some-bucket", Name: "prod/migrations/7_foobar.up.sql", Content: []byte("7 up")},
{BucketName: "some-bucket", Name: "prod/migrations/7_foobar.down.sql", Content: []byte("7 down")},
{BucketName: "some-bucket", Name: "prod/migrations/not-a-migration.txt"},
{BucketName: "some-bucket", Name: "prod/migrations/0-random-stuff/whatever.txt"},
})
defer server.Stop()
driver := gcs{
bucket: server.Client().Bucket("some-bucket"),
prefix: "prod/migrations/",
migrations: source.NewMigrations(),
}
err := driver.loadMigrations()
if err != nil {
t.Fatal(err)
}
st.Test(t, &driver)
}