mirror of
https://github.com/status-im/migrate.git
synced 2025-02-23 08:18:07 +00:00
* Enabled maligned check * Enabled staticcheck * Fixes for golint * Enabled errcheck linter * Added fixes for error check * Added errcheck for tests * Fixed test * Increased golangci-lint deadline for travis * Increased golangci-lint deadline for travis * Decreased golangci-lint deadline for travis * Revert for backward compatibility * Using log.Println() instead of fmt.Println() * Handling os.RemoveAll() errors * Using t.Error(error) instead of t.Errorf("%v", err) * Using t.Fatal(error) instead of t.Fatalf("%v", err) * Using fmt.Sprint(sum) instead of t.Srintf("%v", sum) * Refactoring * Revert for backward compatibility * Revert * go mod tidy * Added error logging * Added error logging * Added error handling * Added error handling * Added error logging * Fix error logging * Added error handling * Fix * Added logging for migr.Buffer() * Fixes * Firebird test disabled * Fixed nolint comment * Updated firebird docker image version * Disabled test for firebird 2.5 * Fixed // nolint
40 lines
1.0 KiB
Go
40 lines
1.0 KiB
Go
// 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, migration []byte) {
|
|
if migration == nil {
|
|
panic("test must provide migration reader")
|
|
}
|
|
|
|
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)
|
|
}
|
|
}
|