test: consolidate failure guards and trim unused fixture APIs

This commit is contained in:
morluto
2026-10-09 03:13:43 +08:00
parent 81ae838567
commit ffd9611308
38 changed files with 90 additions and 203 deletions
+1 -14
View File
@@ -1,11 +1,4 @@
import {
mkdir,
mkdtemp,
readFile,
realpath,
rm,
writeFile,
} from "node:fs/promises";
import { mkdir, mkdtemp, realpath, rm, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
@@ -13,12 +6,9 @@ import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
export interface TestWorkspace {
readonly root: string;
readonly home: string;
readonly xdgConfigHome: string;
readonly xdgCacheHome: string;
readonly environment: NodeJS.ProcessEnv;
path(...segments: readonly string[]): string;
mkdir(relativePath: string): Promise<string>;
read(relativePath: string): Promise<string>;
write(relativePath: string, contents: string | Uint8Array): Promise<string>;
}
@@ -64,8 +54,6 @@ export const createTestWorkspace = async (
return {
root,
home,
xdgConfigHome,
xdgCacheHome,
environment: {
HOME: home,
XDG_CONFIG_HOME: xdgConfigHome,
@@ -77,7 +65,6 @@ export const createTestWorkspace = async (
await mkdir(path, { recursive: true });
return path;
},
read: (relativePath) => readFile(resolvePath(relativePath), "utf8"),
write: async (relativePath, contents) => {
const path = resolvePath(relativePath);
await mkdir(dirname(path), { recursive: true });