mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-09-24 15:49:09 +00:00
127f32822f
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.
23 lines
660 B
TypeScript
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,
|
|
);
|
|
});
|