test: consolidate failure guards and trim unused fixture APIs
This commit is contained in:
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user