fix: Add Plugin Mocks to Provider Tests (#8276)
This commit is contained in:
committed by
GitHub
parent
774c24e76e
commit
452f11ff77
@@ -1,6 +1,4 @@
|
|||||||
import z from "zod"
|
import z from "zod"
|
||||||
import path from "path"
|
|
||||||
import os from "os"
|
|
||||||
import fuzzysort from "fuzzysort"
|
import fuzzysort from "fuzzysort"
|
||||||
import { Config } from "../config/config"
|
import { Config } from "../config/config"
|
||||||
import { mapValues, mergeDeep, omit, pickBy, sortBy } from "remeda"
|
import { mapValues, mergeDeep, omit, pickBy, sortBy } from "remeda"
|
||||||
@@ -605,13 +603,13 @@ export namespace Provider {
|
|||||||
},
|
},
|
||||||
experimentalOver200K: model.cost?.context_over_200k
|
experimentalOver200K: model.cost?.context_over_200k
|
||||||
? {
|
? {
|
||||||
cache: {
|
cache: {
|
||||||
read: model.cost.context_over_200k.cache_read ?? 0,
|
read: model.cost.context_over_200k.cache_read ?? 0,
|
||||||
write: model.cost.context_over_200k.cache_write ?? 0,
|
write: model.cost.context_over_200k.cache_write ?? 0,
|
||||||
},
|
},
|
||||||
input: model.cost.context_over_200k.input,
|
input: model.cost.context_over_200k.input,
|
||||||
output: model.cost.context_over_200k.output,
|
output: model.cost.context_over_200k.output,
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
},
|
},
|
||||||
limit: {
|
limit: {
|
||||||
|
|||||||
@@ -1,5 +1,27 @@
|
|||||||
import { test, expect } from "bun:test"
|
import { test, expect, mock } from "bun:test"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
|
|
||||||
|
// Mock BunProc and default plugins to prevent actual installations during tests
|
||||||
|
mock.module("../../src/bun/index", () => ({
|
||||||
|
BunProc: {
|
||||||
|
install: async (pkg: string, _version?: string) => {
|
||||||
|
// Return package name without version for mocking
|
||||||
|
const lastAtIndex = pkg.lastIndexOf("@")
|
||||||
|
return lastAtIndex > 0 ? pkg.substring(0, lastAtIndex) : pkg
|
||||||
|
},
|
||||||
|
run: async () => {
|
||||||
|
throw new Error("BunProc.run should not be called in tests")
|
||||||
|
},
|
||||||
|
which: () => process.execPath,
|
||||||
|
InstallFailedError: class extends Error {},
|
||||||
|
},
|
||||||
|
}))
|
||||||
|
|
||||||
|
const mockPlugin = () => ({})
|
||||||
|
mock.module("opencode-copilot-auth", () => ({ default: mockPlugin }))
|
||||||
|
mock.module("opencode-anthropic-auth", () => ({ default: mockPlugin }))
|
||||||
|
mock.module("@gitlab/opencode-gitlab-auth", () => ({ default: mockPlugin }))
|
||||||
|
|
||||||
import { tmpdir } from "../fixture/fixture"
|
import { tmpdir } from "../fixture/fixture"
|
||||||
import { Instance } from "../../src/project/instance"
|
import { Instance } from "../../src/project/instance"
|
||||||
import { Provider } from "../../src/provider/provider"
|
import { Provider } from "../../src/provider/provider"
|
||||||
|
|||||||
Reference in New Issue
Block a user