github.com/solvedata/migrate/v4@v4.8.7-0.20201127053940-c9fba4ce569f/database/testing/migrate_testing.go (about) 1 // Package testing has the database tests. 2 // All database drivers must pass the Test function. 3 // This lives in it's own package so it stays a test dependency. 4 package testing 5 6 import ( 7 "testing" 8 ) 9 10 import ( 11 "github.com/solvedata/migrate/v4" 12 ) 13 14 // TestMigrate runs integration-tests between the Migrate layer and database implementations. 15 // 16 func TestMigrate(t *testing.T, m *migrate.Migrate, migration []byte) { 17 if migration == nil { 18 panic("test must provide migration reader") 19 } 20 21 TestMigrateUp(t, m) 22 TestMigrateDrop(t, m) 23 } 24 25 // Regression test for preventing a regression for #164 https://github.com/solvedata/migrate/pull/173 26 // Similar to TestDrop(), but tests the dropping mechanism through the Migrate logic instead, to check for 27 // double-locking during the Drop logic. 28 func TestMigrateDrop(t *testing.T, m *migrate.Migrate) { 29 if err := m.Drop(); err != nil { 30 t.Fatal(err) 31 } 32 } 33 34 func TestMigrateUp(t *testing.T, m *migrate.Migrate) { 35 t.Log("UP") 36 if err := m.Up(); err != nil { 37 t.Fatal(err) 38 } 39 }