fix(test): silence expected oauth logout cli output
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { describe, it, expect, beforeEach, afterEach, mock } from "bun:test"
|
import { afterEach, beforeEach, describe, expect, it, spyOn } from "bun:test"
|
||||||
import { existsSync, mkdirSync, rmSync } from "node:fs"
|
import { existsSync, mkdirSync, rmSync } from "node:fs"
|
||||||
import { join } from "node:path"
|
import { join } from "node:path"
|
||||||
import { tmpdir } from "node:os"
|
import { tmpdir } from "node:os"
|
||||||
@@ -9,10 +9,14 @@ const { logout } = await import("./logout")
|
|||||||
describe("logout command", () => {
|
describe("logout command", () => {
|
||||||
const TEST_CONFIG_DIR = join(tmpdir(), "mcp-oauth-logout-test-" + Date.now())
|
const TEST_CONFIG_DIR = join(tmpdir(), "mcp-oauth-logout-test-" + Date.now())
|
||||||
let originalConfigDir: string | undefined
|
let originalConfigDir: string | undefined
|
||||||
|
let consoleErrorSpy: ReturnType<typeof spyOn>
|
||||||
|
let consoleLogSpy: ReturnType<typeof spyOn>
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
originalConfigDir = process.env.OPENCODE_CONFIG_DIR
|
originalConfigDir = process.env.OPENCODE_CONFIG_DIR
|
||||||
process.env.OPENCODE_CONFIG_DIR = TEST_CONFIG_DIR
|
process.env.OPENCODE_CONFIG_DIR = TEST_CONFIG_DIR
|
||||||
|
consoleErrorSpy = spyOn(console, "error").mockImplementation(() => {})
|
||||||
|
consoleLogSpy = spyOn(console, "log").mockImplementation(() => {})
|
||||||
if (!existsSync(TEST_CONFIG_DIR)) {
|
if (!existsSync(TEST_CONFIG_DIR)) {
|
||||||
mkdirSync(TEST_CONFIG_DIR, { recursive: true })
|
mkdirSync(TEST_CONFIG_DIR, { recursive: true })
|
||||||
}
|
}
|
||||||
@@ -27,6 +31,8 @@ describe("logout command", () => {
|
|||||||
if (existsSync(TEST_CONFIG_DIR)) {
|
if (existsSync(TEST_CONFIG_DIR)) {
|
||||||
rmSync(TEST_CONFIG_DIR, { recursive: true, force: true })
|
rmSync(TEST_CONFIG_DIR, { recursive: true, force: true })
|
||||||
}
|
}
|
||||||
|
consoleErrorSpy.mockRestore()
|
||||||
|
consoleLogSpy.mockRestore()
|
||||||
})
|
})
|
||||||
|
|
||||||
it("returns success code when logout succeeds", async () => {
|
it("returns success code when logout succeeds", async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user