-
Notifications
You must be signed in to change notification settings - Fork 0
/
migrator_test.go
53 lines (41 loc) · 991 Bytes
/
migrator_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
package chorm
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
)
func TestMigrator(t *testing.T) {
tAssert := assert.New(t)
ctx, ctxCancel := context.WithCancel(context.Background())
defer ctxCancel()
orm, err := NewORM(ctx, &Config{
Host: "localhost",
Port: 9000,
Username: "default",
Password: "local12345",
Database: "unpack",
Insecure: true,
})
defer orm.Close()
tAssert.NoError(err)
tAssert.NotNil(orm)
migrator := orm.GetMigrator()
tAssert.NotNil(migrator)
err = migrator.Setup(ctx, nil)
tAssert.NoError(err)
err = migrator.RegisterMigration(
"some-name",
func(ctx context.Context, orm *ORM, migrator *Migrator) error {
return nil
},
func(ctx context.Context, orm *ORM, migrator *Migrator) error {
return nil
},
)
tAssert.NoError(err)
tAssert.Equal(1, len(migrator.GetMigrations()))
err = migrator.Migrate(ctx, nil)
tAssert.NoError(err)
//err = migrator.Destroy(ctx, nil)
//tAssert.NoError(err)
}