test(skill-loader): fix test isolation by resetting skill content
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
parent
65043a7e94
commit
85932fadc7
@ -1,6 +1,34 @@
|
|||||||
import { describe, it, expect } from "bun:test"
|
/// <reference types="bun-types" />
|
||||||
|
|
||||||
|
import { describe, it, expect, beforeEach, afterEach } from "bun:test"
|
||||||
|
import { join } from "node:path"
|
||||||
|
import { tmpdir } from "node:os"
|
||||||
import { resolveSkillContent, resolveMultipleSkills, resolveSkillContentAsync, resolveMultipleSkillsAsync } from "./skill-content"
|
import { resolveSkillContent, resolveMultipleSkills, resolveSkillContentAsync, resolveMultipleSkillsAsync } from "./skill-content"
|
||||||
|
|
||||||
|
let originalEnv: Record<string, string | undefined>
|
||||||
|
let testConfigDir: string
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
originalEnv = {
|
||||||
|
CLAUDE_CONFIG_DIR: process.env.CLAUDE_CONFIG_DIR,
|
||||||
|
OPENCODE_CONFIG_DIR: process.env.OPENCODE_CONFIG_DIR,
|
||||||
|
}
|
||||||
|
const unique = `skill-content-test-${Date.now()}-${Math.random().toString(16).slice(2)}`
|
||||||
|
testConfigDir = join(tmpdir(), unique)
|
||||||
|
process.env.CLAUDE_CONFIG_DIR = testConfigDir
|
||||||
|
process.env.OPENCODE_CONFIG_DIR = testConfigDir
|
||||||
|
})
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
for (const [key, value] of Object.entries(originalEnv)) {
|
||||||
|
if (value !== undefined) {
|
||||||
|
process.env[key] = value
|
||||||
|
} else {
|
||||||
|
delete process.env[key]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
describe("resolveSkillContent", () => {
|
describe("resolveSkillContent", () => {
|
||||||
it("should return template for existing skill", () => {
|
it("should return template for existing skill", () => {
|
||||||
// given: builtin skills with 'frontend-ui-ux' skill
|
// given: builtin skills with 'frontend-ui-ux' skill
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user