mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-22 22:52:03 +00:00
test(hooks): dedupe unsupported npm spec assertion
This commit is contained in:
@@ -60,6 +60,17 @@ function writeArchiveFixture(params: { fileName: string; contents: Buffer }) {
|
||||
};
|
||||
}
|
||||
|
||||
async function expectUnsupportedNpmSpec(
|
||||
install: (spec: string) => Promise<{ ok: boolean; error?: string }>,
|
||||
) {
|
||||
const result = await install("github:evil/evil");
|
||||
expect(result.ok).toBe(false);
|
||||
if (result.ok) {
|
||||
return;
|
||||
}
|
||||
expect(result.error).toContain("unsupported npm spec");
|
||||
}
|
||||
|
||||
describe("installHooksFromArchive", () => {
|
||||
it.each([
|
||||
{
|
||||
@@ -365,12 +376,7 @@ describe("installHooksFromNpmSpec", () => {
|
||||
});
|
||||
|
||||
it("rejects non-registry npm specs", async () => {
|
||||
const result = await installHooksFromNpmSpec({ spec: "github:evil/evil" });
|
||||
expect(result.ok).toBe(false);
|
||||
if (result.ok) {
|
||||
return;
|
||||
}
|
||||
expect(result.error).toContain("unsupported npm spec");
|
||||
await expectUnsupportedNpmSpec((spec) => installHooksFromNpmSpec({ spec }));
|
||||
});
|
||||
|
||||
it("aborts when integrity drift callback rejects the fetched artifact", async () => {
|
||||
|
||||
Reference in New Issue
Block a user