Skip to content

Commit

Permalink
Move tests into migrations_test package
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-farries committed Jan 6, 2025
1 parent 439b0b4 commit f991389
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions pkg/migrations/migrations_test.go
Original file line number Diff line number Diff line change
@@ -1,40 +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) {
t.Parallel()

migration := Migration{
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) {
t.Parallel()

migration := Migration{
migration := migrations.Migration{
Name: "sql",
Operations: Operations{
&OpRawSQL{
Operations: migrations.Operations{
&migrations.OpRawSQL{
Up: `foo`,
},
},
Expand All @@ -46,14 +47,14 @@ func TestMigrationsIsolatedValid(t *testing.T) {
func TestOnCompleteSQLMigrationsAreNotIsolated(t *testing.T) {
t.Parallel()

migration := Migration{
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 f991389

Please sign in to comment.