test(auto-update): update tests to use canonical package name oh-my-openagent

This commit is contained in:
YeonGyu-Kim
2026-04-05 08:31:53 +09:00
parent 3df5497784
commit d7d3698f70
3 changed files with 44 additions and 44 deletions
@@ -21,18 +21,18 @@ describe("pinned-version-updater", () => {
test("updates pinned version in config", () => {
//#given
const config = JSON.stringify({
plugin: ["oh-my-opencode@3.1.8"],
plugin: ["oh-my-openagent@3.1.8"],
})
fs.writeFileSync(configPath, config)
//#when
const result = updatePinnedVersion(configPath, "oh-my-opencode@3.1.8", "3.4.0")
const result = updatePinnedVersion(configPath, "oh-my-openagent@3.1.8", "3.4.0")
//#then
expect(result).toBe(true)
const updated = fs.readFileSync(configPath, "utf-8")
expect(updated).toContain("oh-my-opencode@3.4.0")
expect(updated).not.toContain("oh-my-opencode@3.1.8")
expect(updated).toContain("oh-my-openagent@3.4.0")
expect(updated).not.toContain("oh-my-openagent@3.1.8")
})
test("returns false when entry not found", () => {
@@ -43,7 +43,7 @@ describe("pinned-version-updater", () => {
fs.writeFileSync(configPath, config)
//#when
const result = updatePinnedVersion(configPath, "oh-my-opencode@3.1.8", "3.4.0")
const result = updatePinnedVersion(configPath, "oh-my-openagent@3.1.8", "3.4.0")
//#then
expect(result).toBe(false)
@@ -55,7 +55,7 @@ describe("pinned-version-updater", () => {
fs.writeFileSync(configPath, config)
//#when
const result = updatePinnedVersion(configPath, "oh-my-opencode@3.1.8", "3.4.0")
const result = updatePinnedVersion(configPath, "oh-my-openagent@3.1.8", "3.4.0")
//#then
expect(result).toBe(false)
@@ -66,46 +66,46 @@ describe("pinned-version-updater", () => {
test("reverts from failed version back to original entry", () => {
//#given
const config = JSON.stringify({
plugin: ["oh-my-opencode@3.4.0"],
plugin: ["oh-my-openagent@3.4.0"],
})
fs.writeFileSync(configPath, config)
//#when
const result = revertPinnedVersion(configPath, "3.4.0", "oh-my-opencode@3.1.8")
const result = revertPinnedVersion(configPath, "3.4.0", "oh-my-openagent@3.1.8")
//#then
expect(result).toBe(true)
const reverted = fs.readFileSync(configPath, "utf-8")
expect(reverted).toContain("oh-my-opencode@3.1.8")
expect(reverted).not.toContain("oh-my-opencode@3.4.0")
expect(reverted).toContain("oh-my-openagent@3.1.8")
expect(reverted).not.toContain("oh-my-openagent@3.4.0")
})
test("reverts to unpinned entry", () => {
//#given
const config = JSON.stringify({
plugin: ["oh-my-opencode@3.4.0"],
plugin: ["oh-my-openagent@3.4.0"],
})
fs.writeFileSync(configPath, config)
//#when
const result = revertPinnedVersion(configPath, "3.4.0", "oh-my-opencode")
const result = revertPinnedVersion(configPath, "3.4.0", "oh-my-openagent")
//#then
expect(result).toBe(true)
const reverted = fs.readFileSync(configPath, "utf-8")
expect(reverted).toContain('"oh-my-opencode"')
expect(reverted).not.toContain("oh-my-opencode@3.4.0")
expect(reverted).toContain('"oh-my-openagent"')
expect(reverted).not.toContain("oh-my-openagent@3.4.0")
})
test("returns false when failed version not found", () => {
//#given
const config = JSON.stringify({
plugin: ["oh-my-opencode@3.1.8"],
plugin: ["oh-my-openagent@3.1.8"],
})
fs.writeFileSync(configPath, config)
//#when
const result = revertPinnedVersion(configPath, "3.4.0", "oh-my-opencode@3.1.8")
const result = revertPinnedVersion(configPath, "3.4.0", "oh-my-openagent@3.1.8")
//#then
expect(result).toBe(false)
@@ -116,18 +116,18 @@ describe("pinned-version-updater", () => {
test("config returns to original state after update + revert", () => {
//#given
const originalConfig = JSON.stringify({
plugin: ["oh-my-opencode@3.1.8"],
plugin: ["oh-my-openagent@3.1.8"],
})
fs.writeFileSync(configPath, originalConfig)
//#when
updatePinnedVersion(configPath, "oh-my-opencode@3.1.8", "3.4.0")
revertPinnedVersion(configPath, "3.4.0", "oh-my-opencode@3.1.8")
updatePinnedVersion(configPath, "oh-my-openagent@3.1.8", "3.4.0")
revertPinnedVersion(configPath, "3.4.0", "oh-my-openagent@3.1.8")
//#then
const finalConfig = fs.readFileSync(configPath, "utf-8")
expect(finalConfig).toContain("oh-my-opencode@3.1.8")
expect(finalConfig).not.toContain("oh-my-opencode@3.4.0")
expect(finalConfig).toContain("oh-my-openagent@3.1.8")
expect(finalConfig).not.toContain("oh-my-openagent@3.4.0")
})
})
})
})
@@ -21,7 +21,7 @@ describe("findPluginEntry", () => {
test("returns unpinned for bare package name", () => {
// #given plugin is configured without a tag
fs.writeFileSync(configPath, JSON.stringify({ plugin: ["oh-my-opencode"] }))
fs.writeFileSync(configPath, JSON.stringify({ plugin: ["oh-my-openagent"] }))
// #when plugin entry is detected
const pluginInfo = findPluginEntry(temporaryDirectory)
@@ -34,7 +34,7 @@ describe("findPluginEntry", () => {
test("returns unpinned for latest dist-tag", () => {
// #given plugin is configured with latest dist-tag
fs.writeFileSync(configPath, JSON.stringify({ plugin: ["oh-my-opencode@latest"] }))
fs.writeFileSync(configPath, JSON.stringify({ plugin: ["oh-my-openagent@latest"] }))
// #when plugin entry is detected
const pluginInfo = findPluginEntry(temporaryDirectory)
@@ -47,7 +47,7 @@ describe("findPluginEntry", () => {
test("returns unpinned for beta dist-tag", () => {
// #given plugin is configured with beta dist-tag
fs.writeFileSync(configPath, JSON.stringify({ plugin: ["oh-my-opencode@beta"] }))
fs.writeFileSync(configPath, JSON.stringify({ plugin: ["oh-my-openagent@beta"] }))
// #when plugin entry is detected
const pluginInfo = findPluginEntry(temporaryDirectory)
@@ -60,7 +60,7 @@ describe("findPluginEntry", () => {
test("returns pinned for explicit semver", () => {
// #given plugin is configured with explicit version
fs.writeFileSync(configPath, JSON.stringify({ plugin: ["oh-my-opencode@3.5.2"] }))
fs.writeFileSync(configPath, JSON.stringify({ plugin: ["oh-my-openagent@3.5.2"] }))
// #when plugin entry is detected
const pluginInfo = findPluginEntry(temporaryDirectory)
@@ -11,7 +11,7 @@ type ToastMessageGetter = (isUpdate: boolean, version?: string) => string
function createPluginEntry(overrides?: Partial<PluginEntryInfo>): PluginEntryInfo {
return {
entry: "oh-my-opencode@3.4.0",
entry: "oh-my-openagent@3.4.0",
isPinned: false,
pinnedVersion: null,
configPath: "/test/opencode.json",
@@ -50,7 +50,7 @@ function createRunner() {
configJson: join(TEST_CONFIG_DIR, "opencode.json"),
configJsonc: join(TEST_CONFIG_DIR, "opencode.jsonc"),
packageJson: join(TEST_CONFIG_DIR, "package.json"),
omoConfig: join(TEST_CONFIG_DIR, "oh-my-opencode.json"),
omoConfig: join(TEST_CONFIG_DIR, "oh-my-openagent.json"),
}),
invalidatePackage: mockInvalidatePackage as never,
extractChannel: mockExtractChannel,
@@ -102,11 +102,11 @@ describe("workspace resolution", () => {
it("#given config-dir install exists but cache-dir does not #when updating #then it installs to config-dir", async () => {
// #given
const runBackgroundUpdateCheck = createRunner()
mkdirSync(join(TEST_CONFIG_DIR, "node_modules", "oh-my-opencode"), { recursive: true })
writeFileSync(join(TEST_CONFIG_DIR, "package.json"), JSON.stringify({ dependencies: { "oh-my-opencode": "3.4.0" } }, null, 2))
mkdirSync(join(TEST_CONFIG_DIR, "node_modules", "oh-my-openagent"), { recursive: true })
writeFileSync(join(TEST_CONFIG_DIR, "package.json"), JSON.stringify({ dependencies: { "oh-my-openagent": "3.4.0" } }, null, 2))
writeFileSync(
join(TEST_CONFIG_DIR, "node_modules", "oh-my-opencode", "package.json"),
JSON.stringify({ name: "oh-my-opencode", version: "3.4.0" }, null, 2),
join(TEST_CONFIG_DIR, "node_modules", "oh-my-openagent", "package.json"),
JSON.stringify({ name: "oh-my-openagent", version: "3.4.0" }, null, 2),
)
// #when
@@ -119,17 +119,17 @@ describe("workspace resolution", () => {
it("#given both config-dir and cache-dir installs exist #when updating #then it prefers config-dir", async () => {
// #given
const runBackgroundUpdateCheck = createRunner()
mkdirSync(join(TEST_CONFIG_DIR, "node_modules", "oh-my-opencode"), { recursive: true })
writeFileSync(join(TEST_CONFIG_DIR, "package.json"), JSON.stringify({ dependencies: { "oh-my-opencode": "3.4.0" } }, null, 2))
mkdirSync(join(TEST_CONFIG_DIR, "node_modules", "oh-my-openagent"), { recursive: true })
writeFileSync(join(TEST_CONFIG_DIR, "package.json"), JSON.stringify({ dependencies: { "oh-my-openagent": "3.4.0" } }, null, 2))
writeFileSync(
join(TEST_CONFIG_DIR, "node_modules", "oh-my-opencode", "package.json"),
JSON.stringify({ name: "oh-my-opencode", version: "3.4.0" }, null, 2),
join(TEST_CONFIG_DIR, "node_modules", "oh-my-openagent", "package.json"),
JSON.stringify({ name: "oh-my-openagent", version: "3.4.0" }, null, 2),
)
mkdirSync(join(TEST_CACHE_DIR, "node_modules", "oh-my-opencode"), { recursive: true })
writeFileSync(join(TEST_CACHE_DIR, "package.json"), JSON.stringify({ dependencies: { "oh-my-opencode": "3.4.0" } }, null, 2))
mkdirSync(join(TEST_CACHE_DIR, "node_modules", "oh-my-openagent"), { recursive: true })
writeFileSync(join(TEST_CACHE_DIR, "package.json"), JSON.stringify({ dependencies: { "oh-my-openagent": "3.4.0" } }, null, 2))
writeFileSync(
join(TEST_CACHE_DIR, "node_modules", "oh-my-opencode", "package.json"),
JSON.stringify({ name: "oh-my-opencode", version: "3.4.0" }, null, 2),
join(TEST_CACHE_DIR, "node_modules", "oh-my-openagent", "package.json"),
JSON.stringify({ name: "oh-my-openagent", version: "3.4.0" }, null, 2),
)
// #when
@@ -142,11 +142,11 @@ describe("workspace resolution", () => {
it("#given only cache-dir install exists #when updating #then it falls back to cache-dir", async () => {
// #given
const runBackgroundUpdateCheck = createRunner()
mkdirSync(join(TEST_CACHE_DIR, "node_modules", "oh-my-opencode"), { recursive: true })
writeFileSync(join(TEST_CACHE_DIR, "package.json"), JSON.stringify({ dependencies: { "oh-my-opencode": "3.4.0" } }, null, 2))
mkdirSync(join(TEST_CACHE_DIR, "node_modules", "oh-my-openagent"), { recursive: true })
writeFileSync(join(TEST_CACHE_DIR, "package.json"), JSON.stringify({ dependencies: { "oh-my-openagent": "3.4.0" } }, null, 2))
writeFileSync(
join(TEST_CACHE_DIR, "node_modules", "oh-my-opencode", "package.json"),
JSON.stringify({ name: "oh-my-opencode", version: "3.4.0" }, null, 2),
join(TEST_CACHE_DIR, "node_modules", "oh-my-openagent", "package.json"),
JSON.stringify({ name: "oh-my-openagent", version: "3.4.0" }, null, 2),
)
// #when