init-action: inhibit non-empty dbLocation warning when restarting

This commit is contained in:
Chuan-kai Lin
2025-07-28 14:13:40 -07:00
parent bc9c32ed0b
commit ee698cb5ba
3 changed files with 37 additions and 4 deletions
+28
View File
@@ -92,6 +92,7 @@ for (const { runnerEnv, ErrorConstructor, message } of [
cleanupDatabaseClusterDirectory(
createTestConfig({ dbLocation }),
getRecordingLogger(messages),
{},
() => {
throw new Error(rmSyncError);
},
@@ -112,6 +113,33 @@ for (const { runnerEnv, ErrorConstructor, message } of [
});
}
test("cleanupDatabaseClusterDirectory can disable warning with options", async (t) => {
await withTmpDir(async (tmpDir: string) => {
const dbLocation = path.resolve(tmpDir, "dbs");
fs.mkdirSync(dbLocation, { recursive: true });
const fileToCleanUp = path.resolve(dbLocation, "something-to-cleanup.txt");
fs.writeFileSync(fileToCleanUp, "");
const messages: LoggedMessage[] = [];
cleanupDatabaseClusterDirectory(
createTestConfig({ dbLocation }),
getRecordingLogger(messages),
{ disableExistingDirectoryWarning: true },
);
// Should only have the info message, not the warning
t.is(messages.length, 1);
t.is(messages[0].type, "info");
t.is(
messages[0].message,
`Cleaned up database cluster directory ${dbLocation}.`,
);
t.false(fs.existsSync(fileToCleanUp));
});
});
type PackInfo = {
language: KnownLanguage;
packinfoContents: string | undefined;