Migrate config agent tests to instance fixtures (#28213)
This commit is contained in:
@@ -602,118 +602,87 @@ it.instance("handles agent configuration", () =>
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
test("treats agent variant as model-scoped setting (not provider option)", async () => {
|
it.instance("treats agent variant as model-scoped setting (not provider option)", () =>
|
||||||
await using tmp = await tmpdir({
|
Effect.gen(function* () {
|
||||||
init: async (dir) => {
|
const test = yield* TestInstance
|
||||||
await writeConfig(dir, {
|
yield* writeConfigEffect(test.directory, {
|
||||||
$schema: "https://opencode.ai/config.json",
|
$schema: "https://opencode.ai/config.json",
|
||||||
agent: {
|
agent: {
|
||||||
test_agent: {
|
test_agent: {
|
||||||
model: "openai/gpt-5.2",
|
model: "openai/gpt-5.2",
|
||||||
variant: "xhigh",
|
variant: "xhigh",
|
||||||
max_tokens: 123,
|
max_tokens: 123,
|
||||||
},
|
|
||||||
},
|
},
|
||||||
})
|
},
|
||||||
},
|
})
|
||||||
})
|
const config = yield* Config.Service.use((svc) => svc.get())
|
||||||
|
const agent = config.agent?.["test_agent"]
|
||||||
|
|
||||||
await withTestInstance({
|
expect(agent?.variant).toBe("xhigh")
|
||||||
directory: tmp.path,
|
expect(agent?.options).toMatchObject({
|
||||||
fn: async (ctx) => {
|
max_tokens: 123,
|
||||||
const config = await load(ctx)
|
})
|
||||||
const agent = config.agent?.["test_agent"]
|
expect(agent?.options).not.toHaveProperty("variant")
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
expect(agent?.variant).toBe("xhigh")
|
it.instance("handles command configuration", () =>
|
||||||
expect(agent?.options).toMatchObject({
|
Effect.gen(function* () {
|
||||||
max_tokens: 123,
|
const test = yield* TestInstance
|
||||||
})
|
yield* writeConfigEffect(test.directory, {
|
||||||
expect(agent?.options).not.toHaveProperty("variant")
|
$schema: "https://opencode.ai/config.json",
|
||||||
},
|
command: {
|
||||||
})
|
test_command: {
|
||||||
})
|
template: "test template",
|
||||||
|
description: "test command",
|
||||||
test("handles command configuration", async () => {
|
agent: "test_agent",
|
||||||
await using tmp = await tmpdir({
|
|
||||||
init: async (dir) => {
|
|
||||||
await writeConfig(dir, {
|
|
||||||
$schema: "https://opencode.ai/config.json",
|
|
||||||
command: {
|
|
||||||
test_command: {
|
|
||||||
template: "test template",
|
|
||||||
description: "test command",
|
|
||||||
agent: "test_agent",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
})
|
},
|
||||||
},
|
})
|
||||||
})
|
const config = yield* Config.Service.use((svc) => svc.get())
|
||||||
await withTestInstance({
|
expect(config.command?.["test_command"]).toEqual({
|
||||||
directory: tmp.path,
|
template: "test template",
|
||||||
fn: async (ctx) => {
|
description: "test command",
|
||||||
const config = await load(ctx)
|
agent: "test_agent",
|
||||||
expect(config.command?.["test_command"]).toEqual({
|
})
|
||||||
template: "test template",
|
}),
|
||||||
description: "test command",
|
)
|
||||||
agent: "test_agent",
|
|
||||||
})
|
|
||||||
},
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
test("migrates autoshare to share field", async () => {
|
it.instance("migrates autoshare to share field", () =>
|
||||||
await using tmp = await tmpdir({
|
Effect.gen(function* () {
|
||||||
init: async (dir) => {
|
const test = yield* TestInstance
|
||||||
await Filesystem.write(
|
yield* writeConfigEffect(test.directory, {
|
||||||
path.join(dir, "opencode.json"),
|
$schema: "https://opencode.ai/config.json",
|
||||||
JSON.stringify({
|
autoshare: true,
|
||||||
$schema: "https://opencode.ai/config.json",
|
})
|
||||||
autoshare: true,
|
const config = yield* Config.Service.use((svc) => svc.get())
|
||||||
}),
|
expect(config.share).toBe("auto")
|
||||||
)
|
expect(config.autoshare).toBe(true)
|
||||||
},
|
}),
|
||||||
})
|
)
|
||||||
await withTestInstance({
|
|
||||||
directory: tmp.path,
|
|
||||||
fn: async (ctx) => {
|
|
||||||
const config = await load(ctx)
|
|
||||||
expect(config.share).toBe("auto")
|
|
||||||
expect(config.autoshare).toBe(true)
|
|
||||||
},
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
test("migrates mode field to agent field", async () => {
|
it.instance("migrates mode field to agent field", () =>
|
||||||
await using tmp = await tmpdir({
|
Effect.gen(function* () {
|
||||||
init: async (dir) => {
|
const test = yield* TestInstance
|
||||||
await Filesystem.write(
|
yield* writeConfigEffect(test.directory, {
|
||||||
path.join(dir, "opencode.json"),
|
$schema: "https://opencode.ai/config.json",
|
||||||
JSON.stringify({
|
mode: {
|
||||||
$schema: "https://opencode.ai/config.json",
|
test_mode: {
|
||||||
mode: {
|
model: "test/model",
|
||||||
test_mode: {
|
temperature: 0.5,
|
||||||
model: "test/model",
|
},
|
||||||
temperature: 0.5,
|
},
|
||||||
},
|
})
|
||||||
},
|
const config = yield* Config.Service.use((svc) => svc.get())
|
||||||
}),
|
expect(config.agent?.["test_mode"]).toEqual({
|
||||||
)
|
model: "test/model",
|
||||||
},
|
temperature: 0.5,
|
||||||
})
|
mode: "primary",
|
||||||
await withTestInstance({
|
options: {},
|
||||||
directory: tmp.path,
|
permission: {},
|
||||||
fn: async (ctx) => {
|
})
|
||||||
const config = await load(ctx)
|
}),
|
||||||
expect(config.agent?.["test_mode"]).toEqual({
|
)
|
||||||
model: "test/model",
|
|
||||||
temperature: 0.5,
|
|
||||||
mode: "primary",
|
|
||||||
options: {},
|
|
||||||
permission: {},
|
|
||||||
})
|
|
||||||
},
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
test("loads config from .opencode directory", async () => {
|
test("loads config from .opencode directory", async () => {
|
||||||
await using tmp = await tmpdir({
|
await using tmp = await tmpdir({
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ Repeated setup work, long sleeps/timeouts, serial integration tests, filesystem/
|
|||||||
| Provider env precedence and model lookup cases can use Effect-aware instance fixtures | Migrated four more provider lookup/default-model cases to `it.instance` | 6.12s | 6.36s | keep | Noisy 5-run median; kept as a small stacked cleanup slice but do not claim speedup from this migration. |
|
| Provider env precedence and model lookup cases can use Effect-aware instance fixtures | Migrated four more provider lookup/default-model cases to `it.instance` | 6.12s | 6.36s | keep | Noisy 5-run median; kept as a small stacked cleanup slice but do not claim speedup from this migration. |
|
||||||
| Simple config load cases can use Effect-aware instance fixtures | Migrated JSON, shell, formatter, and lsp config load cases to `it.instance` | 14.18s | 3.93s | keep | Three-run medians before/after; removes manual `tmpdir` + `withTestInstance` setup from the first simple config block. |
|
| Simple config load cases can use Effect-aware instance fixtures | Migrated JSON, shell, formatter, and lsp config load cases to `it.instance` | 14.18s | 3.93s | keep | Three-run medians before/after; removes manual `tmpdir` + `withTestInstance` setup from the first simple config block. |
|
||||||
| Config template, file include, and simple agent cases can use Effect-aware instance fixtures | Migrated JSONC, env/file substitution, invalid config, and agent config cases to `it.instance` | 1.87s | 1.90s | keep | Stacked on the first config slice; neutral timing but removes more manual `tmpdir` + instance plumbing. |
|
| Config template, file include, and simple agent cases can use Effect-aware instance fixtures | Migrated JSONC, env/file substitution, invalid config, and agent config cases to `it.instance` | 1.87s | 1.90s | keep | Stacked on the first config slice; neutral timing but removes more manual `tmpdir` + instance plumbing. |
|
||||||
|
| Agent option, command, and legacy migration config cases can use Effect-aware instance fixtures | Migrated agent variant, command, autoshare, and mode migration cases to `it.instance` | 1.90s | 1.83s | keep | Stacked on the config template slice; small neutral-to-positive timing and less manual setup. |
|
||||||
|
|
||||||
## Profiling Results
|
## Profiling Results
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user