From 5c44365697c6735b0d738e97d7bec2fde73c664c Mon Sep 17 00:00:00 2001 From: Andrew Farries Date: Mon, 6 Jan 2025 12:22:58 +0000 Subject: [PATCH] Make `migrations_test.go` tests consistent with other tests in `pkg/migrations` (#568) Update the tests in `migrations_test.go`: * Put them in the `migrations_test` package * Add `t.Parallel()` to each test This makes the tests in this file consistent with the other tests in `pkg/migrations`. --- pkg/migrations/migrations_test.go | 33 +++++++++++++++++++------------ 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/pkg/migrations/migrations_test.go b/pkg/migrations/migrations_test.go index a14613529..92b741746 100644 --- a/pkg/migrations/migrations_test.go +++ b/pkg/migrations/migrations_test.go @@ -1,36 +1,41 @@ // SPDX-License-Identifier: Apache-2.0 -package migrations +package migrations_test import ( "context" "testing" "github.com/stretchr/testify/assert" + "github.com/xataio/pgroll/pkg/migrations" "github.com/xataio/pgroll/pkg/schema" ) func TestMigrationsIsolated(t *testing.T) { - migration := Migration{ + t.Parallel() + + migration := migrations.Migration{ Name: "sql", - Operations: Operations{ - &OpRawSQL{ + Operations: migrations.Operations{ + &migrations.OpRawSQL{ Up: `foo`, }, - &OpCreateTable{Name: "foo"}, + &migrations.OpCreateTable{Name: "foo"}, }, } err := migration.Validate(context.TODO(), schema.New()) - var wantErr InvalidMigrationError + var wantErr migrations.InvalidMigrationError assert.ErrorAs(t, err, &wantErr) } func TestMigrationsIsolatedValid(t *testing.T) { - migration := Migration{ + t.Parallel() + + migration := migrations.Migration{ Name: "sql", - Operations: Operations{ - &OpRawSQL{ + Operations: migrations.Operations{ + &migrations.OpRawSQL{ Up: `foo`, }, }, @@ -40,14 +45,16 @@ func TestMigrationsIsolatedValid(t *testing.T) { } func TestOnCompleteSQLMigrationsAreNotIsolated(t *testing.T) { - migration := Migration{ + t.Parallel() + + migration := migrations.Migration{ Name: "sql", - Operations: Operations{ - &OpRawSQL{ + Operations: migrations.Operations{ + &migrations.OpRawSQL{ Up: `foo`, OnComplete: true, }, - &OpCreateTable{Name: "foo"}, + &migrations.OpCreateTable{Name: "foo"}, }, } err := migration.Validate(context.TODO(), schema.New())