Migrate simple config tests to instance fixtures (#28210)
This commit is contained in:
@@ -94,14 +94,6 @@ const listDirs = (ctx: InstanceContext) =>
|
|||||||
Effect.provide(layer),
|
Effect.provide(layer),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
const ready = (ctx: InstanceContext) =>
|
|
||||||
Effect.runPromise(
|
|
||||||
Config.Service.use((svc) => provideCurrentInstance(svc.waitForDependencies(), ctx)).pipe(
|
|
||||||
Effect.scoped,
|
|
||||||
Effect.provide(layer),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
// Get managed config directory from environment (set in preload.ts)
|
// Get managed config directory from environment (set in preload.ts)
|
||||||
const managedConfigDir = process.env.OPENCODE_TEST_MANAGED_CONFIG_DIR!
|
const managedConfigDir = process.env.OPENCODE_TEST_MANAGED_CONFIG_DIR!
|
||||||
|
|
||||||
@@ -210,43 +202,24 @@ test("does not create global config when OPENCODE_CONFIG_DIR is set", async () =
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
test("loads JSON config file", async () => {
|
it.instance(
|
||||||
await using tmp = await tmpdir({
|
"loads JSON config file",
|
||||||
init: async (dir) => {
|
Effect.gen(function* () {
|
||||||
await writeConfig(dir, {
|
const config = yield* Config.Service.use((svc) => svc.get())
|
||||||
$schema: "https://opencode.ai/config.json",
|
expect(config.model).toBe("test/model")
|
||||||
model: "test/model",
|
expect(config.username).toBe("testuser")
|
||||||
username: "testuser",
|
}),
|
||||||
})
|
{ config: { model: "test/model", username: "testuser" } },
|
||||||
},
|
)
|
||||||
})
|
|
||||||
await withTestInstance({
|
|
||||||
directory: tmp.path,
|
|
||||||
fn: async (ctx) => {
|
|
||||||
const config = await load(ctx)
|
|
||||||
expect(config.model).toBe("test/model")
|
|
||||||
expect(config.username).toBe("testuser")
|
|
||||||
},
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
test("loads shell config field", async () => {
|
it.instance(
|
||||||
await using tmp = await tmpdir({
|
"loads shell config field",
|
||||||
init: async (dir) => {
|
Effect.gen(function* () {
|
||||||
await writeConfig(dir, {
|
const config = yield* Config.Service.use((svc) => svc.get())
|
||||||
$schema: "https://opencode.ai/config.json",
|
expect(config.shell).toBe("bash")
|
||||||
shell: "bash",
|
}),
|
||||||
})
|
{ config: { shell: "bash" } },
|
||||||
},
|
)
|
||||||
})
|
|
||||||
await withTestInstance({
|
|
||||||
directory: tmp.path,
|
|
||||||
fn: async (ctx) => {
|
|
||||||
const config = await load(ctx)
|
|
||||||
expect(config.shell).toBe("bash")
|
|
||||||
},
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
test("updates config and preserves empty shell sentinel", async () => {
|
test("updates config and preserves empty shell sentinel", async () => {
|
||||||
await using tmp = await tmpdir({
|
await using tmp = await tmpdir({
|
||||||
@@ -330,41 +303,23 @@ test("updates global config and omits empty shell key in jsonc", async () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
test("loads formatter boolean config", async () => {
|
it.instance(
|
||||||
await using tmp = await tmpdir({
|
"loads formatter boolean config",
|
||||||
init: async (dir) => {
|
Effect.gen(function* () {
|
||||||
await writeConfig(dir, {
|
const config = yield* Config.Service.use((svc) => svc.get())
|
||||||
$schema: "https://opencode.ai/config.json",
|
expect(config.formatter).toBe(true)
|
||||||
formatter: true,
|
}),
|
||||||
})
|
{ config: { formatter: true } },
|
||||||
},
|
)
|
||||||
})
|
|
||||||
await withTestInstance({
|
|
||||||
directory: tmp.path,
|
|
||||||
fn: async (ctx) => {
|
|
||||||
const config = await load(ctx)
|
|
||||||
expect(config.formatter).toBe(true)
|
|
||||||
},
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
test("loads lsp boolean config", async () => {
|
it.instance(
|
||||||
await using tmp = await tmpdir({
|
"loads lsp boolean config",
|
||||||
init: async (dir) => {
|
Effect.gen(function* () {
|
||||||
await writeConfig(dir, {
|
const config = yield* Config.Service.use((svc) => svc.get())
|
||||||
$schema: "https://opencode.ai/config.json",
|
expect(config.lsp).toBe(true)
|
||||||
lsp: true,
|
}),
|
||||||
})
|
{ config: { lsp: true } },
|
||||||
},
|
)
|
||||||
})
|
|
||||||
await withTestInstance({
|
|
||||||
directory: tmp.path,
|
|
||||||
fn: async (ctx) => {
|
|
||||||
const config = await load(ctx)
|
|
||||||
expect(config.lsp).toBe(true)
|
|
||||||
},
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
test("loads project config from Git Bash and MSYS2 paths on Windows", async () => {
|
test("loads project config from Git Bash and MSYS2 paths on Windows", async () => {
|
||||||
// Git Bash and MSYS2 both use /<drive>/... paths on Windows.
|
// Git Bash and MSYS2 both use /<drive>/... paths on Windows.
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ Repeated setup work, long sleeps/timeouts, serial integration tests, filesystem/
|
|||||||
| First provider config/env/filtering block can use Effect-aware instance fixtures | Migrated six `tmpdir` + `withTestInstance` cases to `it.instance` | 6.06s | 6.07s | keep | Neutral timing, but removes manual config file writes and instance plumbing; use as the pattern for later provider slices. |
|
| First provider config/env/filtering block can use Effect-aware instance fixtures | Migrated six `tmpdir` + `withTestInstance` cases to `it.instance` | 6.06s | 6.07s | keep | Neutral timing, but removes manual config file writes and instance plumbing; use as the pattern for later provider slices. |
|
||||||
| Custom provider/model config cases can use Effect-aware instance fixtures | Migrated three more config-heavy provider cases to `it.instance` | 6.07s | 6.12s | keep | Neutral timing within noise, but continues removing manual config file writes on top of the first provider fixture PR. |
|
| Custom provider/model config cases can use Effect-aware instance fixtures | Migrated three more config-heavy provider cases to `it.instance` | 6.07s | 6.12s | keep | Neutral timing within noise, but continues removing manual config file writes on top of the first provider fixture PR. |
|
||||||
| 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. |
|
||||||
|
|
||||||
## Profiling Results
|
## Profiling Results
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user