diff --git a/src/shared/migrate-legacy-config-file.test.ts b/src/shared/migrate-legacy-config-file.test.ts index 7fd8a1d7a..0277b11bc 100644 --- a/src/shared/migrate-legacy-config-file.test.ts +++ b/src/shared/migrate-legacy-config-file.test.ts @@ -1,4 +1,4 @@ -import { afterEach, beforeEach, describe, expect, it } from "bun:test" +import { afterEach, beforeEach, describe, expect, it, mock } from "bun:test" import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs" import { tmpdir } from "node:os" import { join } from "node:path" @@ -87,4 +87,26 @@ describe("migrateLegacyConfigFile", () => { }) }) }) + + describe("#given canonical write succeeds but archive fails", () => { + describe("#when migrating the config file", () => { + it("#then returns true", () => { + const legacyPath = join(testDir, "oh-my-opencode.jsonc") + const backupPath = `${legacyPath}.bak` + const canonicalPath = join(testDir, "oh-my-openagent.jsonc") + writeFileSync(legacyPath, '{ "agents": {} }') + + // given: create backup path as directory (blocks rename, causing archive to return false) + mkdirSync(backupPath) + + // when: migrate the config file + const result = migrateLegacyConfigFile(legacyPath) + + // then: migration should return true (canonical write succeeded, archive is optional) + expect(result).toBe(true) + // then: canonical file should exist + expect(existsSync(canonicalPath)).toBe(true) + }) + }) + }) }) diff --git a/src/shared/migrate-legacy-config-file.ts b/src/shared/migrate-legacy-config-file.ts index 03c0c6241..2affcab54 100644 --- a/src/shared/migrate-legacy-config-file.ts +++ b/src/shared/migrate-legacy-config-file.ts @@ -58,7 +58,7 @@ export function migrateLegacyConfigFile(legacyPath: string): boolean { to: canonicalPath, archivedLegacyConfig, }) - return archivedLegacyConfig + return true } catch (error) { log("[migrateLegacyConfigFile] Failed to migrate legacy config file", { legacyPath, error }) return false