Skip to content

Commit

Permalink
test: also remove any repair migrations as part of test cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
SandPod committed Nov 17, 2023
1 parent 73d3199 commit d2b40d7
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ abstract class MigrationTestUtils {
required Client serviceClient,
}) async {
removeAllTaggedMigrations();
removeRepairMigration();
_removeMigrationTestProtocolFolder();
if (resetSql != null) {
await _resetDatabase(resetSql: resetSql, serviceClient: serviceClient);
Expand All @@ -73,6 +74,13 @@ abstract class MigrationTestUtils {
await _setDatabaseMigrationToLatestInRegistry(serviceClient: serviceClient);
}

static void removeRepairMigration() {
var repairMigrationDirectory = _repairMigrationDirectory();
if (repairMigrationDirectory.existsSync()) {
repairMigrationDirectory.deleteSync(recursive: true);
}
}

static void removeAllTaggedMigrations() {
for (var entity in _migrationsProjectDirectory().listSync()) {
if (entity is Directory) {
Expand Down Expand Up @@ -117,10 +125,19 @@ abstract class MigrationTestUtils {
'migration_test_protocol_files',
));

static Directory _migrationsProjectDirectory() => Directory(path.join(
static Directory _migrationDirectory() => Directory(path.join(
Directory.current.path,
'generated',
'migration',
));

static Directory _repairMigrationDirectory() => Directory(path.join(
_migrationDirectory().path,
'repair',
));

static Directory _migrationsProjectDirectory() => Directory(path.join(
_migrationDirectory().path,
'migrations',
'serverpod_test',
));
Expand Down

0 comments on commit d2b40d7

Please sign in to comment.