mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-17 19:20:39 +09:00
Address dev runner snapshot review feedback
This commit is contained in:
parent
8f25ba6381
commit
dc58544832
2 changed files with 24 additions and 6 deletions
|
|
@ -9,7 +9,12 @@ const defaultFileSystem = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export function isMissingPathError(error) {
|
export function isMissingPathError(error) {
|
||||||
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
return (
|
||||||
|
typeof error === "object" &&
|
||||||
|
error !== null &&
|
||||||
|
"code" in error &&
|
||||||
|
(error.code === "ENOENT" || error.code === "ENOTDIR")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function toRelativePath(repoRoot, absolutePath) {
|
function toRelativePath(repoRoot, absolutePath) {
|
||||||
|
|
|
||||||
|
|
@ -52,8 +52,9 @@ describe("dev-runner watched snapshot", () => {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(() => collectWatchedSnapshot({ ...createSnapshotOptions(root), fileSystem })).not.toThrow();
|
const snapshot = collectWatchedSnapshot({ ...createSnapshotOptions(root), fileSystem });
|
||||||
expect(collectWatchedSnapshot(createSnapshotOptions(root)).has("server/index.ts")).toBe(false);
|
|
||||||
|
expect(snapshot.has("server/index.ts")).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("skips directories that disappear before they can be read", () => {
|
it("skips directories that disappear before they can be read", () => {
|
||||||
|
|
@ -74,15 +75,27 @@ describe("dev-runner watched snapshot", () => {
|
||||||
statSync: fs.statSync,
|
statSync: fs.statSync,
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(() => collectWatchedSnapshot({ ...createSnapshotOptions(root), fileSystem })).not.toThrow();
|
const snapshot = collectWatchedSnapshot({ ...createSnapshotOptions(root), fileSystem });
|
||||||
expect(collectWatchedSnapshot(createSnapshotOptions(root)).has("server/routes/health.ts")).toBe(false);
|
|
||||||
|
expect(snapshot.has("server/routes/health.ts")).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("returns null for missing file signatures and reports deleted paths in diffs", () => {
|
it("returns null for missing file signatures and not-directory races", () => {
|
||||||
const root = createTempRoot("paperclip-dev-runner-snapshot-diff-");
|
const root = createTempRoot("paperclip-dev-runner-snapshot-diff-");
|
||||||
const missingPath = path.join(root, "server", "deleted.ts");
|
const missingPath = path.join(root, "server", "deleted.ts");
|
||||||
|
const fileSystem = {
|
||||||
|
statSync() {
|
||||||
|
const error = new Error("not a directory") as NodeJS.ErrnoException;
|
||||||
|
error.code = "ENOTDIR";
|
||||||
|
throw error;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
expect(readSignature(missingPath)).toBeNull();
|
expect(readSignature(missingPath)).toBeNull();
|
||||||
|
expect(readSignature(missingPath, fileSystem)).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("reports deleted paths in diffs", () => {
|
||||||
expect(diffSnapshots(new Map([["server/deleted.ts", "1:1"]]), new Map())).toEqual(["server/deleted.ts"]);
|
expect(diffSnapshots(new Map([["server/deleted.ts", "1:1"]]), new Map())).toEqual(["server/deleted.ts"]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue