diff --git a/globals_test.go b/globals_test.go index 1c1dfe339..638e830ba 100644 --- a/globals_test.go +++ b/globals_test.go @@ -18,14 +18,14 @@ func TestNewGoMigration(t *testing.T) { require.Equal(t, m.Next, int64(-1)) require.Equal(t, m.Previous, int64(-1)) require.Equal(t, m.Source, "") - require.True(t, m.UpFnNoTxContext == nil) - require.True(t, m.DownFnNoTxContext == nil) - require.True(t, m.UpFnContext == nil) - require.True(t, m.DownFnContext == nil) - require.True(t, m.UpFn == nil) - require.True(t, m.DownFn == nil) - require.True(t, m.UpFnNoTx == nil) - require.True(t, m.DownFnNoTx == nil) + require.Nil(t, m.UpFnNoTxContext) + require.Nil(t, m.DownFnNoTxContext) + require.Nil(t, m.UpFnContext) + require.Nil(t, m.DownFnContext) + require.Nil(t, m.UpFn) + require.Nil(t, m.DownFn) + require.Nil(t, m.UpFnNoTx) + require.Nil(t, m.DownFnNoTx) require.True(t, m.goUp != nil) require.True(t, m.goDown != nil) require.Equal(t, m.goUp.Mode, TransactionEnabled) @@ -149,18 +149,18 @@ func TestLegacyFunctions(t *testing.T) { m := registeredGoMigrations[1] assertMigration(t, m, 1) // Legacy functions. - require.True(t, m.UpFnNoTxContext == nil) - require.True(t, m.DownFnNoTxContext == nil) + require.Nil(t, m.UpFnNoTxContext) + require.Nil(t, m.DownFnNoTxContext) // Context-aware functions. - require.False(t, m.goUp == nil) - require.False(t, m.UpFnContext == nil) - require.False(t, m.goDown == nil) - require.False(t, m.DownFnContext == nil) + require.NotNil(t, m.goUp) + require.NotNil(t, m.UpFnContext) + require.NotNil(t, m.goDown) + require.NotNil(t, m.DownFnContext) // Always nil - require.False(t, m.UpFn == nil) - require.False(t, m.DownFn == nil) - require.True(t, m.UpFnNoTx == nil) - require.True(t, m.DownFnNoTx == nil) + require.NotNil(t, m.UpFn) + require.NotNil(t, m.DownFn) + require.Nil(t, m.UpFnNoTx) + require.Nil(t, m.DownFnNoTx) }) t.Run("all_db", func(t *testing.T) { t.Cleanup(ResetGlobalMigrations) @@ -172,18 +172,18 @@ func TestLegacyFunctions(t *testing.T) { m := registeredGoMigrations[2] assertMigration(t, m, 2) // Legacy functions. - require.False(t, m.UpFnNoTxContext == nil) - require.False(t, m.goUp == nil) - require.False(t, m.DownFnNoTxContext == nil) - require.False(t, m.goDown == nil) + require.NotNil(t, m.UpFnNoTxContext) + require.NotNil(t, m.goUp) + require.NotNil(t, m.DownFnNoTxContext) + require.NotNil(t, m.goDown) // Context-aware functions. - require.True(t, m.UpFnContext == nil) - require.True(t, m.DownFnContext == nil) + require.Nil(t, m.UpFnContext) + require.Nil(t, m.DownFnContext) // Always nil - require.True(t, m.UpFn == nil) - require.True(t, m.DownFn == nil) - require.False(t, m.UpFnNoTx == nil) - require.False(t, m.DownFnNoTx == nil) + require.Nil(t, m.UpFn) + require.Nil(t, m.DownFn) + require.NotNil(t, m.UpFnNoTx) + require.NotNil(t, m.DownFnNoTx) }) } diff --git a/provider_run_test.go b/provider_run_test.go index 31402f9ac..793072ba4 100644 --- a/provider_run_test.go +++ b/provider_run_test.go @@ -1085,7 +1085,7 @@ func assertResult(t *testing.T, got *goose.MigrationResult, source *goose.Source require.Equal(t, got.Source, source) require.Equal(t, got.Direction, direction) require.Equal(t, got.Empty, isEmpty) - require.True(t, got.Error == nil) + require.Nil(t, got.Error) require.True(t, got.Duration > 0) } diff --git a/tests/gomigrations/register/register_test.go b/tests/gomigrations/register/register_test.go index 32cfdc7d9..1d5e08d73 100644 --- a/tests/gomigrations/register/register_test.go +++ b/tests/gomigrations/register/register_test.go @@ -65,48 +65,48 @@ func checkFunctions(t *testing.T, m *goose.Migration) { switch filepath.Base(m.Source) { case "001_addmigration.go": // With transaction - require.False(t, m.UpFn == nil) - require.False(t, m.DownFn == nil) - require.False(t, m.UpFnContext == nil) - require.False(t, m.DownFnContext == nil) + require.NotNil(t, m.UpFn) + require.NotNil(t, m.DownFn) + require.NotNil(t, m.UpFnContext) + require.NotNil(t, m.DownFnContext) // No transaction - require.True(t, m.UpFnNoTx == nil) - require.True(t, m.DownFnNoTx == nil) - require.True(t, m.UpFnNoTxContext == nil) - require.True(t, m.DownFnNoTxContext == nil) + require.Nil(t, m.UpFnNoTx) + require.Nil(t, m.DownFnNoTx) + require.Nil(t, m.UpFnNoTxContext) + require.Nil(t, m.DownFnNoTxContext) case "002_addmigrationnotx.go": // With transaction - require.True(t, m.UpFn == nil) - require.True(t, m.DownFn == nil) - require.True(t, m.UpFnContext == nil) - require.True(t, m.DownFnContext == nil) + require.Nil(t, m.UpFn) + require.Nil(t, m.DownFn) + require.Nil(t, m.UpFnContext) + require.Nil(t, m.DownFnContext) // No transaction - require.False(t, m.UpFnNoTx == nil) - require.False(t, m.DownFnNoTx == nil) - require.False(t, m.UpFnNoTxContext == nil) - require.False(t, m.DownFnNoTxContext == nil) + require.NotNil(t, m.UpFnNoTx) + require.NotNil(t, m.DownFnNoTx) + require.NotNil(t, m.UpFnNoTxContext) + require.NotNil(t, m.DownFnNoTxContext) case "003_addmigrationcontext.go": // With transaction - require.False(t, m.UpFn == nil) - require.False(t, m.DownFn == nil) - require.False(t, m.UpFnContext == nil) - require.False(t, m.DownFnContext == nil) + require.NotNil(t, m.UpFn) + require.NotNil(t, m.DownFn) + require.NotNil(t, m.UpFnContext) + require.NotNil(t, m.DownFnContext) // No transaction - require.True(t, m.UpFnNoTx == nil) - require.True(t, m.DownFnNoTx == nil) - require.True(t, m.UpFnNoTxContext == nil) - require.True(t, m.DownFnNoTxContext == nil) + require.Nil(t, m.UpFnNoTx) + require.Nil(t, m.DownFnNoTx) + require.Nil(t, m.UpFnNoTxContext) + require.Nil(t, m.DownFnNoTxContext) case "004_addmigrationnotxcontext.go": // With transaction - require.True(t, m.UpFn == nil) - require.True(t, m.DownFn == nil) - require.True(t, m.UpFnContext == nil) - require.True(t, m.DownFnContext == nil) + require.Nil(t, m.UpFn) + require.Nil(t, m.DownFn) + require.Nil(t, m.UpFnContext) + require.Nil(t, m.DownFnContext) // No transaction - require.False(t, m.UpFnNoTx == nil) - require.False(t, m.DownFnNoTx == nil) - require.False(t, m.UpFnNoTxContext == nil) - require.False(t, m.DownFnNoTxContext == nil) + require.NotNil(t, m.UpFnNoTx) + require.NotNil(t, m.DownFnNoTx) + require.NotNil(t, m.UpFnNoTxContext) + require.NotNil(t, m.DownFnNoTxContext) default: t.Fatalf("unexpected migration: %s", filepath.Base(m.Source)) }