github.com/nagyistzcons/migrate/v4@v4.14.5/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  	"github.com/nagyistzcons/migrate/v4"
    10  )
    11  
    12  // TestMigrate runs integration-tests between the Migrate layer and database implementations.
    13  func TestMigrate(t *testing.T, m *migrate.Migrate) {
    14  	TestMigrateUp(t, m)
    15  	TestMigrateDrop(t, m)
    16  }
    17  
    18  // Regression test for preventing a regression for #164 https://github.com/golang-migrate/migrate/pull/173
    19  // Similar to TestDrop(), but tests the dropping mechanism through the Migrate logic instead, to check for
    20  // double-locking during the Drop logic.
    21  func TestMigrateDrop(t *testing.T, m *migrate.Migrate) {
    22  	if err := m.Drop(); err != nil {
    23  		t.Fatal(err)
    24  	}
    25  }
    26  
    27  func TestMigrateUp(t *testing.T, m *migrate.Migrate) {
    28  	t.Log("UP")
    29  	if err := m.Up(); err != nil {
    30  		t.Fatal(err)
    31  	}
    32  }