Migrate custom provider tests to instance fixtures
Migrate the next custom provider/model config tests to Effect-aware instance fixtures while keeping timing neutral and behavior unchanged.
This commit is contained in:
@@ -228,13 +228,17 @@ it.instance(
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
test("custom model alias via config", async () => {
|
it.instance(
|
||||||
await using tmp = await tmpdir({
|
"custom model alias via config",
|
||||||
init: async (dir) => {
|
Effect.gen(function* () {
|
||||||
await Bun.write(
|
yield* setProcessEnv("ANTHROPIC_API_KEY", "test-api-key")
|
||||||
path.join(dir, "opencode.json"),
|
const providers = yield* Provider.Service.use((provider) => provider.list())
|
||||||
JSON.stringify({
|
expect(providers[ProviderID.anthropic]).toBeDefined()
|
||||||
$schema: "https://opencode.ai/config.json",
|
expect(providers[ProviderID.anthropic].models["my-alias"]).toBeDefined()
|
||||||
|
expect(providers[ProviderID.anthropic].models["my-alias"].name).toBe("My Custom Alias")
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
config: {
|
||||||
provider: {
|
provider: {
|
||||||
anthropic: {
|
anthropic: {
|
||||||
models: {
|
models: {
|
||||||
@@ -245,29 +249,20 @@ test("custom model alias via config", async () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}),
|
},
|
||||||
|
},
|
||||||
)
|
)
|
||||||
},
|
|
||||||
})
|
|
||||||
await withTestInstance({
|
|
||||||
directory: tmp.path,
|
|
||||||
fn: async (ctx) => {
|
|
||||||
await set(ctx, "ANTHROPIC_API_KEY", "test-api-key")
|
|
||||||
const providers = await list(ctx)
|
|
||||||
expect(providers[ProviderID.anthropic]).toBeDefined()
|
|
||||||
expect(providers[ProviderID.anthropic].models["my-alias"]).toBeDefined()
|
|
||||||
expect(providers[ProviderID.anthropic].models["my-alias"].name).toBe("My Custom Alias")
|
|
||||||
},
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
test("custom provider with npm package", async () => {
|
it.instance(
|
||||||
await using tmp = await tmpdir({
|
"custom provider with npm package",
|
||||||
init: async (dir) => {
|
Effect.gen(function* () {
|
||||||
await Bun.write(
|
const providers = yield* Provider.Service.use((provider) => provider.list())
|
||||||
path.join(dir, "opencode.json"),
|
expect(providers[ProviderID.make("custom-provider")]).toBeDefined()
|
||||||
JSON.stringify({
|
expect(providers[ProviderID.make("custom-provider")].name).toBe("Custom Provider")
|
||||||
$schema: "https://opencode.ai/config.json",
|
expect(providers[ProviderID.make("custom-provider")].models["custom-model"]).toBeDefined()
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
config: {
|
||||||
provider: {
|
provider: {
|
||||||
"custom-provider": {
|
"custom-provider": {
|
||||||
name: "Custom Provider",
|
name: "Custom Provider",
|
||||||
@@ -289,20 +284,9 @@ test("custom provider with npm package", async () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}),
|
},
|
||||||
|
},
|
||||||
)
|
)
|
||||||
},
|
|
||||||
})
|
|
||||||
await withTestInstance({
|
|
||||||
directory: tmp.path,
|
|
||||||
fn: async (ctx) => {
|
|
||||||
const providers = await list(ctx)
|
|
||||||
expect(providers[ProviderID.make("custom-provider")]).toBeDefined()
|
|
||||||
expect(providers[ProviderID.make("custom-provider")].name).toBe("Custom Provider")
|
|
||||||
expect(providers[ProviderID.make("custom-provider")].models["custom-model"]).toBeDefined()
|
|
||||||
},
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
it.instance(
|
it.instance(
|
||||||
"filters alpha provider models by default",
|
"filters alpha provider models by default",
|
||||||
@@ -324,13 +308,20 @@ experimentalModels.instance(
|
|||||||
{ config: alphaProviderConfig },
|
{ config: alphaProviderConfig },
|
||||||
)
|
)
|
||||||
|
|
||||||
test("custom DeepSeek openai-compatible model defaults interleaved reasoning field", async () => {
|
it.instance(
|
||||||
await using tmp = await tmpdir({
|
"custom DeepSeek openai-compatible model defaults interleaved reasoning field",
|
||||||
init: async (dir) => {
|
Effect.gen(function* () {
|
||||||
await Bun.write(
|
const providers = yield* Provider.Service.use((provider) => provider.list())
|
||||||
path.join(dir, "opencode.json"),
|
const provider = providers[ProviderID.make("custom-provider")]
|
||||||
JSON.stringify({
|
expect(provider.models["deepseek-r1"].capabilities.interleaved).toEqual({ field: "reasoning_content" })
|
||||||
$schema: "https://opencode.ai/config.json",
|
expect(provider.models["deepseek-details"].capabilities.interleaved).toEqual({ field: "reasoning_details" })
|
||||||
|
expect(provider.models["custom-model"].capabilities.interleaved).toBe(false)
|
||||||
|
expect(providers[ProviderID.make("custom-anthropic-provider")].models["deepseek-r1"].capabilities.interleaved).toBe(
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
config: {
|
||||||
provider: {
|
provider: {
|
||||||
"custom-provider": {
|
"custom-provider": {
|
||||||
name: "Custom Provider",
|
name: "Custom Provider",
|
||||||
@@ -366,24 +357,9 @@ test("custom DeepSeek openai-compatible model defaults interleaved reasoning fie
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}),
|
},
|
||||||
|
},
|
||||||
)
|
)
|
||||||
},
|
|
||||||
})
|
|
||||||
await withTestInstance({
|
|
||||||
directory: tmp.path,
|
|
||||||
fn: async (ctx) => {
|
|
||||||
const providers = await list(ctx)
|
|
||||||
const provider = providers[ProviderID.make("custom-provider")]
|
|
||||||
expect(provider.models["deepseek-r1"].capabilities.interleaved).toEqual({ field: "reasoning_content" })
|
|
||||||
expect(provider.models["deepseek-details"].capabilities.interleaved).toEqual({ field: "reasoning_details" })
|
|
||||||
expect(provider.models["custom-model"].capabilities.interleaved).toBe(false)
|
|
||||||
expect(
|
|
||||||
providers[ProviderID.make("custom-anthropic-provider")].models["deepseek-r1"].capabilities.interleaved,
|
|
||||||
).toBe(false)
|
|
||||||
},
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
test("env variable takes precedence, config merges options", async () => {
|
test("env variable takes precedence, config merges options", async () => {
|
||||||
await using tmp = await tmpdir({
|
await using tmp = await tmpdir({
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ Repeated setup work, long sleeps/timeouts, serial integration tests, filesystem/
|
|||||||
| HTTP listen PTY ticket tests restart the same listener topology twice | Folded directory-scoped ticket regression into the broader unsafe-ticket test | 7.051s | 6.170s | keep | Two targeted reruns passed after the change: 6.76s, 6.17s; still covers mint failure and successful same-directory upgrade. |
|
| HTTP listen PTY ticket tests restart the same listener topology twice | Folded directory-scoped ticket regression into the broader unsafe-ticket test | 7.051s | 6.170s | keep | Two targeted reruns passed after the change: 6.76s, 6.17s; still covers mint failure and successful same-directory upgrade. |
|
||||||
| File watcher readiness can write before async native subscriptions are active | Retried short readiness writes and accepted symlink-realpath HEAD events | failed | 4.62s | keep | Three sequential focused watcher runs passed: 4.62s, 4.57s, 4.64s; full suite no longer failed in `watcher.test.ts`. |
|
| File watcher readiness can write before async native subscriptions are active | Retried short readiness writes and accepted symlink-realpath HEAD events | failed | 4.62s | keep | Three sequential focused watcher runs passed: 4.62s, 4.57s, 4.64s; full suite no longer failed in `watcher.test.ts`. |
|
||||||
| 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. |
|
||||||
|
|
||||||
## Profiling Results
|
## Profiling Results
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user