opencode/packages/core/test/config/model.test.ts
Shoubhit Dash e57d9ca390
feat(core): flatten provider config and load native packages (#35563)
Co-authored-by: Dax Raad <d@ironbay.co>
2026-07-06 16:18:56 -04:00

28 lines
1.1 KiB
TypeScript

import { describe, expect, test } from "bun:test"
import { ConfigModel } from "@opencode-ai/core/config/model"
import { Model } from "@opencode-ai/schema/model"
import { Provider } from "@opencode-ai/schema/provider"
import { Schema } from "effect"
const decode = Schema.decodeUnknownSync(ConfigModel.Selection)
describe("ConfigModel.Selection", () => {
test("normalizes short and explicit model selections", () => {
expect(decode("openrouter/openai/gpt-5#high")).toEqual({
providerID: Provider.ID.make("openrouter"),
model: Model.ID.make("openai/gpt-5"),
variant: Model.VariantID.make("high"),
})
expect(decode({ providerID: "anthropic", model: "claude-sonnet", variant: "high" })).toEqual({
providerID: Provider.ID.make("anthropic"),
model: Model.ID.make("claude-sonnet"),
variant: Model.VariantID.make("high"),
})
})
test("rejects malformed selections and reserved fragments", () => {
expect(() => decode("gpt-5")).toThrow()
expect(() => decode("openai/gpt-5#")).toThrow()
expect(() => decode({ providerID: "openai", model: "gpt-5#high" })).toThrow()
})
})