snapshot of https://github.com/golang-migrate/migrate.git (master, 2026-09-15; blobs > 131072B omitted)
This commit is contained in:
34
database/testing/migrate_testing.go
Normal file
34
database/testing/migrate_testing.go
Normal file
@@ -0,0 +1,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/golang-migrate/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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user