mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Fix paths in tests
This commit is contained in:
parent
ccce2279c9
commit
5df4671988
2 changed files with 34 additions and 12 deletions
|
|
@ -75,7 +75,9 @@ describe("PowerShell Core shell integration", () => {
|
||||||
|
|
||||||
const content = fs.readFileSync(mockStartupFile, "utf-8");
|
const content = fs.readFileSync(mockStartupFile, "utf-8");
|
||||||
assert.ok(
|
assert.ok(
|
||||||
content.includes(". \"$HOME\\\\.safe-chain\\\\scripts\\\\init-pwsh.ps1\" # Safe-chain PowerShell initialization script")
|
content.includes(
|
||||||
|
'. "$HOME\\.safe-chain\\scripts\\init-pwsh.ps1" # Safe-chain PowerShell initialization script'
|
||||||
|
)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -84,7 +86,7 @@ describe("PowerShell Core shell integration", () => {
|
||||||
it("should remove init-pwsh.ps1 source line", () => {
|
it("should remove init-pwsh.ps1 source line", () => {
|
||||||
const initialContent = [
|
const initialContent = [
|
||||||
"# PowerShell profile",
|
"# PowerShell profile",
|
||||||
". \"$HOME\\\\.safe-chain\\\\scripts\\\\init-pwsh.ps1\" # Safe-chain PowerShell initialization script",
|
'. "$HOME\\.safe-chain\\scripts\\init-pwsh.ps1" # Safe-chain PowerShell initialization script',
|
||||||
"Set-Alias ls Get-ChildItem",
|
"Set-Alias ls Get-ChildItem",
|
||||||
"Set-Alias grep Select-String",
|
"Set-Alias grep Select-String",
|
||||||
].join("\n");
|
].join("\n");
|
||||||
|
|
@ -95,7 +97,9 @@ describe("PowerShell Core shell integration", () => {
|
||||||
assert.strictEqual(result, true);
|
assert.strictEqual(result, true);
|
||||||
|
|
||||||
const content = fs.readFileSync(mockStartupFile, "utf-8");
|
const content = fs.readFileSync(mockStartupFile, "utf-8");
|
||||||
assert.ok(!content.includes(". \"$HOME\\\\.safe-chain\\\\scripts\\\\init-pwsh.ps1\""));
|
assert.ok(
|
||||||
|
!content.includes('. "$HOME\\.safe-chain\\scripts\\init-pwsh.ps1"')
|
||||||
|
);
|
||||||
assert.ok(content.includes("Set-Alias ls "));
|
assert.ok(content.includes("Set-Alias ls "));
|
||||||
assert.ok(content.includes("Set-Alias grep "));
|
assert.ok(content.includes("Set-Alias grep "));
|
||||||
});
|
});
|
||||||
|
|
@ -168,12 +172,16 @@ describe("PowerShell Core shell integration", () => {
|
||||||
// Setup
|
// Setup
|
||||||
powershell.setup();
|
powershell.setup();
|
||||||
let content = fs.readFileSync(mockStartupFile, "utf-8");
|
let content = fs.readFileSync(mockStartupFile, "utf-8");
|
||||||
assert.ok(content.includes(". \"$HOME\\\\.safe-chain\\\\scripts\\\\init-pwsh.ps1\""));
|
assert.ok(
|
||||||
|
content.includes('. "$HOME\\.safe-chain\\scripts\\init-pwsh.ps1"')
|
||||||
|
);
|
||||||
|
|
||||||
// Teardown
|
// Teardown
|
||||||
powershell.teardown(knownAikidoTools);
|
powershell.teardown(knownAikidoTools);
|
||||||
content = fs.readFileSync(mockStartupFile, "utf-8");
|
content = fs.readFileSync(mockStartupFile, "utf-8");
|
||||||
assert.ok(!content.includes(". \"$HOME\\\\.safe-chain\\\\scripts\\\\init-pwsh.ps1\""));
|
assert.ok(
|
||||||
|
!content.includes('. "$HOME\\.safe-chain\\scripts\\init-pwsh.ps1"')
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should handle multiple setup calls", () => {
|
it("should handle multiple setup calls", () => {
|
||||||
|
|
@ -182,7 +190,10 @@ describe("PowerShell Core shell integration", () => {
|
||||||
powershell.setup();
|
powershell.setup();
|
||||||
|
|
||||||
const content = fs.readFileSync(mockStartupFile, "utf-8");
|
const content = fs.readFileSync(mockStartupFile, "utf-8");
|
||||||
const sourceMatches = (content.match(/\. "\$HOME\\\\.safe-chain\\\\scripts\\\\init-pwsh\.ps1"/g) || []).length;
|
const sourceMatches = (
|
||||||
|
content.match(/\. "\$HOME\\.safe-chain\\scripts\\init-pwsh\.ps1"/g) ||
|
||||||
|
[]
|
||||||
|
).length;
|
||||||
assert.strictEqual(sourceMatches, 1, "Should not duplicate source lines");
|
assert.strictEqual(sourceMatches, 1, "Should not duplicate source lines");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,9 @@ describe("Windows PowerShell shell integration", () => {
|
||||||
|
|
||||||
const content = fs.readFileSync(mockStartupFile, "utf-8");
|
const content = fs.readFileSync(mockStartupFile, "utf-8");
|
||||||
assert.ok(
|
assert.ok(
|
||||||
content.includes(". \"$HOME\\\\.safe-chain\\\\scripts\\\\init-pwsh.ps1\" # Safe-chain PowerShell initialization script")
|
content.includes(
|
||||||
|
'. "$HOME\\.safe-chain\\scripts\\init-pwsh.ps1" # Safe-chain PowerShell initialization script'
|
||||||
|
)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -84,7 +86,7 @@ describe("Windows PowerShell shell integration", () => {
|
||||||
it("should remove init-pwsh.ps1 source line", () => {
|
it("should remove init-pwsh.ps1 source line", () => {
|
||||||
const initialContent = [
|
const initialContent = [
|
||||||
"# Windows PowerShell profile",
|
"# Windows PowerShell profile",
|
||||||
". \"$HOME\\\\.safe-chain\\\\scripts\\\\init-pwsh.ps1\" # Safe-chain PowerShell initialization script",
|
'. "$HOME\\.safe-chain\\scripts\\init-pwsh.ps1" # Safe-chain PowerShell initialization script',
|
||||||
"Set-Alias ls Get-ChildItem",
|
"Set-Alias ls Get-ChildItem",
|
||||||
"Set-Alias grep Select-String",
|
"Set-Alias grep Select-String",
|
||||||
].join("\n");
|
].join("\n");
|
||||||
|
|
@ -95,7 +97,9 @@ describe("Windows PowerShell shell integration", () => {
|
||||||
assert.strictEqual(result, true);
|
assert.strictEqual(result, true);
|
||||||
|
|
||||||
const content = fs.readFileSync(mockStartupFile, "utf-8");
|
const content = fs.readFileSync(mockStartupFile, "utf-8");
|
||||||
assert.ok(!content.includes(". \"$HOME\\\\.safe-chain\\\\scripts\\\\init-pwsh.ps1\""));
|
assert.ok(
|
||||||
|
!content.includes('. "$HOME\\.safe-chain\\scripts\\init-pwsh.ps1"')
|
||||||
|
);
|
||||||
assert.ok(content.includes("Set-Alias ls "));
|
assert.ok(content.includes("Set-Alias ls "));
|
||||||
assert.ok(content.includes("Set-Alias grep "));
|
assert.ok(content.includes("Set-Alias grep "));
|
||||||
});
|
});
|
||||||
|
|
@ -168,12 +172,16 @@ describe("Windows PowerShell shell integration", () => {
|
||||||
// Setup
|
// Setup
|
||||||
windowsPowershell.setup();
|
windowsPowershell.setup();
|
||||||
let content = fs.readFileSync(mockStartupFile, "utf-8");
|
let content = fs.readFileSync(mockStartupFile, "utf-8");
|
||||||
assert.ok(content.includes(". \"$HOME\\\\.safe-chain\\\\scripts\\\\init-pwsh.ps1\""));
|
assert.ok(
|
||||||
|
content.includes('. "$HOME\\.safe-chain\\scripts\\init-pwsh.ps1"')
|
||||||
|
);
|
||||||
|
|
||||||
// Teardown
|
// Teardown
|
||||||
windowsPowershell.teardown(knownAikidoTools);
|
windowsPowershell.teardown(knownAikidoTools);
|
||||||
content = fs.readFileSync(mockStartupFile, "utf-8");
|
content = fs.readFileSync(mockStartupFile, "utf-8");
|
||||||
assert.ok(!content.includes(". \"$HOME\\\\.safe-chain\\\\scripts\\\\init-pwsh.ps1\""));
|
assert.ok(
|
||||||
|
!content.includes('. "$HOME\\.safe-chain\\scripts\\init-pwsh.ps1"')
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should handle multiple setup calls", () => {
|
it("should handle multiple setup calls", () => {
|
||||||
|
|
@ -182,7 +190,10 @@ describe("Windows PowerShell shell integration", () => {
|
||||||
windowsPowershell.setup();
|
windowsPowershell.setup();
|
||||||
|
|
||||||
const content = fs.readFileSync(mockStartupFile, "utf-8");
|
const content = fs.readFileSync(mockStartupFile, "utf-8");
|
||||||
const sourceMatches = (content.match(/\. "\$HOME\\\\.safe-chain\\\\scripts\\\\init-pwsh\.ps1"/g) || []).length;
|
const sourceMatches = (
|
||||||
|
content.match(/\. "\$HOME\\.safe-chain\\scripts\\init-pwsh\.ps1"/g) ||
|
||||||
|
[]
|
||||||
|
).length;
|
||||||
assert.strictEqual(sourceMatches, 1, "Should not duplicate source lines");
|
assert.strictEqual(sourceMatches, 1, "Should not duplicate source lines");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue