From f991389b6189d3d93d8d699a962e504c85df572f Mon Sep 17 00:00:00 2001 From: Andrew Farries Date: Mon, 6 Jan 2025 07:37:24 +0000 Subject: [PATCH] Move tests into `migrations_test` package --- pkg/migrations/migrations_test.go | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/pkg/migrations/migrations_test.go b/pkg/migrations/migrations_test.go index 0d4d3243..92b74174 100644 --- a/pkg/migrations/migrations_test.go +++ b/pkg/migrations/migrations_test.go @@ -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`, }, }, @@ -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())