test(skill-mcp): fix connection env var tests after oauth-handler import changes
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -12,18 +12,18 @@ const mockGetOrCreateClientWithRetryImpl = mock(async () => ({
|
|||||||
close: mock(async () => {}),
|
close: mock(async () => {}),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
mock.module("./connection", () => ({
|
|
||||||
getOrCreateClient: mockGetOrCreateClient,
|
|
||||||
getOrCreateClientWithRetryImpl: mockGetOrCreateClientWithRetryImpl,
|
|
||||||
}))
|
|
||||||
|
|
||||||
mock.module("../mcp-oauth/provider", () => ({
|
|
||||||
McpOAuthProvider: class MockMcpOAuthProvider {},
|
|
||||||
}))
|
|
||||||
|
|
||||||
type ManagerModule = typeof import("./manager")
|
type ManagerModule = typeof import("./manager")
|
||||||
|
|
||||||
async function importFreshManagerModule(): Promise<ManagerModule> {
|
async function importFreshManagerModule(): Promise<ManagerModule> {
|
||||||
|
mock.module("./connection", () => ({
|
||||||
|
getOrCreateClient: mockGetOrCreateClient,
|
||||||
|
getOrCreateClientWithRetryImpl: mockGetOrCreateClientWithRetryImpl,
|
||||||
|
}))
|
||||||
|
|
||||||
|
mock.module("../mcp-oauth/provider", () => ({
|
||||||
|
McpOAuthProvider: class MockMcpOAuthProvider {},
|
||||||
|
}))
|
||||||
|
|
||||||
return await import(new URL(`./manager.ts?oauth-retry-test=${Date.now()}-${Math.random()}`, import.meta.url).href)
|
return await import(new URL(`./manager.ts?oauth-retry-test=${Date.now()}-${Math.random()}`, import.meta.url).href)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
import { beforeEach, describe, expect, it, mock } from "bun:test"
|
import { describe, expect, it, mock } from "bun:test"
|
||||||
import type { ClaudeCodeMcpServer } from "../claude-code-mcp-loader/types"
|
import type { ClaudeCodeMcpServer } from "../claude-code-mcp-loader/types"
|
||||||
import type { OAuthTokenData } from "../mcp-oauth/storage"
|
import type { OAuthTokenData } from "../mcp-oauth/storage"
|
||||||
import type { OAuthProviderFactory, OAuthProviderLike } from "./types"
|
import type { OAuthProviderFactory, OAuthProviderLike } from "./types"
|
||||||
|
|
||||||
mock.module("../mcp-oauth/provider", () => ({
|
|
||||||
McpOAuthProvider: class MockMcpOAuthProvider {},
|
|
||||||
}))
|
|
||||||
|
|
||||||
type OAuthHandlerModule = typeof import("./oauth-handler")
|
type OAuthHandlerModule = typeof import("./oauth-handler")
|
||||||
|
|
||||||
async function importFreshOAuthHandlerModule(): Promise<OAuthHandlerModule> {
|
async function importFreshOAuthHandlerModule(): Promise<OAuthHandlerModule> {
|
||||||
|
mock.module("../mcp-oauth/provider", () => ({
|
||||||
|
McpOAuthProvider: class MockMcpOAuthProvider {},
|
||||||
|
}))
|
||||||
|
|
||||||
return await import(new URL(`./oauth-handler.ts?oauth-handler-test=${Date.now()}-${Math.random()}`, import.meta.url).href)
|
return await import(new URL(`./oauth-handler.ts?oauth-handler-test=${Date.now()}-${Math.random()}`, import.meta.url).href)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,10 +41,6 @@ function createConfig(serverUrl: string): ClaudeCodeMcpServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe("oauth-handler refresh mutex wiring", () => {
|
describe("oauth-handler refresh mutex wiring", () => {
|
||||||
beforeEach(() => {
|
|
||||||
mock.restore()
|
|
||||||
})
|
|
||||||
|
|
||||||
it("deduplicates concurrent pre-request refresh attempts for the same server", async () => {
|
it("deduplicates concurrent pre-request refresh attempts for the same server", async () => {
|
||||||
// given
|
// given
|
||||||
const { buildHttpRequestInit } = await importFreshOAuthHandlerModule()
|
const { buildHttpRequestInit } = await importFreshOAuthHandlerModule()
|
||||||
|
|||||||
Reference in New Issue
Block a user