forked from golang-migrate/migrate
/
migrate_testing.go
34 lines (29 loc) · 935 Bytes
/
migrate_testing.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
// Package testing has the database tests.
// All database drivers must pass the Test function.
// This lives in it's own package so it stays a test dependency.
package testing
import (
"testing"
)
import (
"github.com/Sfinks80/golang-migrate/v4"
)
// TestMigrate runs integration-tests between the Migrate layer and database implementations.
func TestMigrate(t *testing.T, m *migrate.Migrate) {
TestMigrateUp(t, m)
TestMigrateDrop(t, m)
}
// Regression test for preventing a regression for #164 https://github.com/golang-migrate/migrate/pull/173
// Similar to TestDrop(), but tests the dropping mechanism through the Migrate logic instead, to check for
// double-locking during the Drop logic.
func TestMigrateDrop(t *testing.T, m *migrate.Migrate) {
if err := m.Drop(); err != nil {
t.Fatal(err)
}
}
func TestMigrateUp(t *testing.T, m *migrate.Migrate) {
t.Log("UP")
if err := m.Up(); err != nil {
t.Fatal(err)
}
}