Skip to content

Commit 04aafe2

Browse files
authored
test(provider): migrate more config-backed cases (#27067)
1 parent 0fd0fac commit 04aafe2

1 file changed

Lines changed: 39 additions & 51 deletions

File tree

packages/opencode/test/provider/provider.test.ts

Lines changed: 39 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -582,64 +582,52 @@ it.instance(
582582
},
583583
)
584584

585-
test("model options are merged from existing model", async () => {
586-
await using tmp = await tmpdir({
587-
init: async (dir) => {
588-
await Bun.write(
589-
path.join(dir, "opencode.json"),
590-
JSON.stringify({
591-
$schema: "https://opencode.ai/config.json",
592-
provider: {
593-
anthropic: {
594-
models: {
595-
"claude-sonnet-4-20250514": {
596-
options: {
597-
customOption: "custom-value",
598-
},
599-
},
585+
it.instance(
586+
"model options are merged from existing model",
587+
Effect.gen(function* () {
588+
const providers = yield* Provider.Service.use((provider) => provider.list())
589+
const model = providers[ProviderID.anthropic].models["claude-sonnet-4-20250514"]
590+
expect(model.options.customOption).toBe("custom-value")
591+
}),
592+
{
593+
config: {
594+
provider: {
595+
anthropic: {
596+
options: {
597+
apiKey: "test-api-key",
598+
},
599+
models: {
600+
"claude-sonnet-4-20250514": {
601+
options: {
602+
customOption: "custom-value",
600603
},
601604
},
602605
},
603-
}),
604-
)
605-
},
606-
})
607-
await WithInstance.provide({
608-
directory: tmp.path,
609-
fn: async () => {
610-
set("ANTHROPIC_API_KEY", "test-api-key")
611-
const providers = await list()
612-
const model = providers[ProviderID.anthropic].models["claude-sonnet-4-20250514"]
613-
expect(model.options.customOption).toBe("custom-value")
606+
},
607+
},
614608
},
615-
})
616-
})
609+
},
610+
)
617611

618-
test("provider removed when all models filtered out", async () => {
619-
await using tmp = await tmpdir({
620-
init: async (dir) => {
621-
await Bun.write(
622-
path.join(dir, "opencode.json"),
623-
JSON.stringify({
624-
$schema: "https://opencode.ai/config.json",
625-
provider: {
626-
anthropic: {
627-
whitelist: ["nonexistent-model"],
628-
},
612+
it.instance(
613+
"provider removed when all models filtered out",
614+
Effect.gen(function* () {
615+
const providers = yield* Provider.Service.use((provider) => provider.list())
616+
expect(providers[ProviderID.anthropic]).toBeUndefined()
617+
}),
618+
{
619+
config: {
620+
provider: {
621+
anthropic: {
622+
options: {
623+
apiKey: "test-api-key",
629624
},
630-
}),
631-
)
632-
},
633-
})
634-
await WithInstance.provide({
635-
directory: tmp.path,
636-
fn: async () => {
637-
set("ANTHROPIC_API_KEY", "test-api-key")
638-
const providers = await list()
639-
expect(providers[ProviderID.anthropic]).toBeUndefined()
625+
whitelist: ["nonexistent-model"],
626+
},
627+
},
640628
},
641-
})
642-
})
629+
},
630+
)
643631

644632
test("closest finds model by partial match", async () => {
645633
await using tmp = await tmpdir({

0 commit comments

Comments
 (0)