-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmigrate_test.go
46 lines (34 loc) · 898 Bytes
/
migrate_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
package migrations
import (
"os"
"testing"
"github.com/keremdokumaci/goql/test/utils"
"github.com/stretchr/testify/suite"
)
type MigrateTestSuite struct {
utils.BaseSuite
}
func (s *MigrateTestSuite) BeforeTest(suiteName, testName string) {
// s.SkipTestIfModeNot(s.T(), utils.INTEGRATION)
}
func (s *MigrateTestSuite) SetupSuite() {
err := s.PostgresConnection()
if err != nil {
s.T().Fatal(err.Error())
}
}
func TestMigrateTestSuite(t *testing.T) {
suite.Run(t, new(MigrateTestSuite))
}
func (s *MigrateTestSuite) TestMigratePostgres() {
os.Setenv("MIGRATION_DIR", "./postgres")
err := MigratePostgres(s.DB)
s.Nil(err)
latestVersion := GetLatestMigrationNumber(os.Getenv("MIGRATION_DIR"))
row := s.DB.QueryRow("select version from public.schema_migrations")
s.Nil(row.Err())
var version uint
err = row.Scan(&version)
s.Nil(err)
s.Equal(latestVersion, version)
}