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