mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-13 15:44:56 +00:00
42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
import { describe, expect } from "bun:test"
|
|
import { Effect } from "effect"
|
|
import { PluginV2 } from "@opencode-ai/core/plugin"
|
|
import { ProviderPlugins } from "@opencode-ai/core/plugin/provider"
|
|
import { NvidiaPlugin } from "@opencode-ai/core/plugin/provider/nvidia"
|
|
import { expectPluginRegistered, it, provider } from "./provider-helper"
|
|
|
|
describe("NvidiaPlugin", () => {
|
|
it.effect("is registered so legacy referer headers can be applied", () =>
|
|
Effect.sync(() =>
|
|
expectPluginRegistered(
|
|
ProviderPlugins.map((item) => item.id),
|
|
"nvidia",
|
|
),
|
|
),
|
|
)
|
|
|
|
it.effect("applies legacy referer headers only to nvidia", () =>
|
|
Effect.gen(function* () {
|
|
const plugin = yield* PluginV2.Service
|
|
yield* plugin.add(NvidiaPlugin)
|
|
const result = yield* plugin.trigger(
|
|
"provider.update",
|
|
{},
|
|
{
|
|
provider: provider("nvidia", {
|
|
options: { headers: { Existing: "value" }, body: {}, aisdk: { provider: {}, request: {} } },
|
|
}),
|
|
cancel: false,
|
|
},
|
|
)
|
|
const ignored = yield* plugin.trigger("provider.update", {}, { provider: provider("openrouter"), cancel: false })
|
|
expect(result.provider.options.headers).toEqual({
|
|
Existing: "value",
|
|
"HTTP-Referer": "https://opencode.ai/",
|
|
"X-Title": "opencode",
|
|
})
|
|
expect(ignored.provider.options.headers).toEqual({})
|
|
}),
|
|
)
|
|
})
|