23 lines
1 KiB
TypeScript
23 lines
1 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
import { test } from "node:test";
|
|
import { manifestPath, stateDir, updateCachePath } from "../src/paths.ts";
|
|
|
|
test("DESIGNPACA_STATE_DIR 은 사용자 홈을 바꾸지 않고 상태 파일만 격리한다", () => {
|
|
const before = process.env["DESIGNPACA_STATE_DIR"];
|
|
const isolated = path.join(os.tmpdir(), "designpaca-isolated-state");
|
|
|
|
try {
|
|
process.env["DESIGNPACA_STATE_DIR"] = isolated;
|
|
assert.equal(stateDir(), path.resolve(isolated));
|
|
assert.equal(manifestPath(), path.join(path.resolve(isolated), "manifest.json"));
|
|
assert.equal(updateCachePath(), path.join(path.resolve(isolated), "update-check.json"));
|
|
|
|
const explicitHome = path.join(os.tmpdir(), "designpaca-explicit-home");
|
|
assert.equal(stateDir(explicitHome), path.join(explicitHome, ".designpaca"));
|
|
} finally {
|
|
if (before === undefined) delete process.env["DESIGNPACA_STATE_DIR"];
|
|
else process.env["DESIGNPACA_STATE_DIR"] = before;
|
|
}
|
|
});
|