Files
Netcatty/domain/sftpStatError.test.ts
T
bincxz 127f32822f fix(sftp): match absence-shaped lstat messages only
Substring search could treat a permission error as missing if the
path contained "enoent". Unwrap the Electron invoke prefix and match
the known ssh2/Node absence kind at the start of that message.
2026-08-14 20:23:24 +08:00

23 lines
660 B
TypeScript

import assert from "node:assert/strict";
import test from "node:test";
import { isMissingStatError } from "./sftpStatError";
test("isMissingStatError recognizes ssh2 and Electron-wrapped absence", () => {
assert.equal(isMissingStatError(new Error("No such file")), true);
assert.equal(
isMissingStatError(
new Error("Error invoking remote method 'netcatty:sftp:lstat': Error: No such file"),
),
true,
);
});
test("isMissingStatError does not treat path substrings as absence", () => {
assert.equal(
isMissingStatError(
new Error("EACCES: permission denied, lstat '/private/enoent/report.txt'"),
),
false,
);
});