Skip to content

Commit

Permalink
Make migrations_test.go tests consistent with other tests in `pkg/m…
Browse files Browse the repository at this point in the history
…igrations` (#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`.
  • Loading branch information
andrew-farries authored Jan 6, 2025
1 parent e6e4523 commit 5c44365
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions pkg/migrations/migrations_test.go
Original file line number Diff line number Diff line change
@@ -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`,
},
},
Expand All @@ -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())
Expand Down

0 comments on commit 5c44365

Please sign in to comment.