Skip to content

Commit 4cd3872

Browse files
authored
feat(test): Add double migration test (#827)
We saw some bugs when the migration code wasn't reliable and, if we ran safe migration after forced one, there would be conflicts reported (where they shouldn't have been). This extra test ensures that the destination is in sync what it scans from database and what is taken from spec.
1 parent f32fac3 commit 4cd3872

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

plugins/destination/plugin_testing_migrate.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/cloudquery/plugin-sdk/v2/types"
1616
"github.com/google/uuid"
1717
"github.com/rs/zerolog"
18+
"github.com/stretchr/testify/require"
1819
)
1920

2021
func tableUUIDSuffix() string {
@@ -241,4 +242,18 @@ func (*PluginTestSuite) destinationPluginTestMigrate(
241242
t.Fatal(err)
242243
}
243244
})
245+
246+
t.Run("double_migration", func(t *testing.T) {
247+
tableName := "double_migration_" + tableUUIDSuffix()
248+
table := schema.CQSchemaToArrow(testdata.TestTable(tableName))
249+
250+
p := newPlugin()
251+
require.NoError(t, p.Init(ctx, logger, spec))
252+
require.NoError(t, p.Migrate(ctx, schema.Schemas{table}))
253+
254+
nonForced := spec
255+
nonForced.MigrateMode = specs.MigrateModeSafe
256+
require.NoError(t, p.Init(ctx, logger, nonForced))
257+
require.NoError(t, p.Migrate(ctx, schema.Schemas{table}))
258+
})
244259
}

0 commit comments

Comments
 (0)