mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Fix tests
This commit is contained in:
parent
87bb095d4f
commit
9476927b87
6 changed files with 39 additions and 18 deletions
|
|
@ -27,10 +27,10 @@ function setup(tools) {
|
||||||
const startupFile = execAndGetOutput(startupFileCommand, executableName);
|
const startupFile = execAndGetOutput(startupFileCommand, executableName);
|
||||||
teardown();
|
teardown();
|
||||||
|
|
||||||
for (const tool of tools) {
|
for (const { tool, aikidoCommand } of tools) {
|
||||||
addLineToFile(
|
addLineToFile(
|
||||||
startupFile,
|
startupFile,
|
||||||
`alias ${tool}="aikido-${tool}" # Safe-chain alias for ${tool}`
|
`alias ${tool}="${aikidoCommand}" # Safe-chain alias for ${tool}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,11 @@ describe("Bash shell integration", () => {
|
||||||
|
|
||||||
describe("setup", () => {
|
describe("setup", () => {
|
||||||
it("should add aliases for all provided tools", () => {
|
it("should add aliases for all provided tools", () => {
|
||||||
const tools = ["npm", "npx", "yarn"];
|
const tools = [
|
||||||
|
{ tool: "npm", aikidoCommand: "aikido-npm" },
|
||||||
|
{ tool: "npx", aikidoCommand: "aikido-npx" },
|
||||||
|
{ tool: "yarn", aikidoCommand: "aikido-yarn" }
|
||||||
|
];
|
||||||
|
|
||||||
const result = bash.setup(tools);
|
const result = bash.setup(tools);
|
||||||
assert.strictEqual(result, true);
|
assert.strictEqual(result, true);
|
||||||
|
|
@ -85,7 +89,7 @@ describe("Bash shell integration", () => {
|
||||||
"utf-8"
|
"utf-8"
|
||||||
);
|
);
|
||||||
|
|
||||||
const tools = ["npm"];
|
const tools = [{ tool: "npm", aikidoCommand: "aikido-npm" }];
|
||||||
bash.setup(tools);
|
bash.setup(tools);
|
||||||
|
|
||||||
const content = fs.readFileSync(mockStartupFile, "utf-8");
|
const content = fs.readFileSync(mockStartupFile, "utf-8");
|
||||||
|
|
@ -171,7 +175,10 @@ describe("Bash shell integration", () => {
|
||||||
|
|
||||||
describe("integration tests", () => {
|
describe("integration tests", () => {
|
||||||
it("should handle complete setup and teardown cycle", () => {
|
it("should handle complete setup and teardown cycle", () => {
|
||||||
const tools = ["npm", "yarn"];
|
const tools = [
|
||||||
|
{ tool: "npm", aikidoCommand: "aikido-npm" },
|
||||||
|
{ tool: "yarn", aikidoCommand: "aikido-yarn" }
|
||||||
|
];
|
||||||
|
|
||||||
// Setup
|
// Setup
|
||||||
bash.setup(tools);
|
bash.setup(tools);
|
||||||
|
|
@ -187,7 +194,7 @@ describe("Bash shell integration", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should handle multiple setup calls", () => {
|
it("should handle multiple setup calls", () => {
|
||||||
const tools = ["npm"];
|
const tools = [{ tool: "npm", aikidoCommand: "aikido-npm" }];
|
||||||
|
|
||||||
bash.setup(tools);
|
bash.setup(tools);
|
||||||
bash.setup(tools);
|
bash.setup(tools);
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,10 @@ function setup(tools) {
|
||||||
const startupFile = execAndGetOutput(startupFileCommand, executableName);
|
const startupFile = execAndGetOutput(startupFileCommand, executableName);
|
||||||
teardown();
|
teardown();
|
||||||
|
|
||||||
for (const tool of tools) {
|
for (const { tool, aikidoCommand } of tools) {
|
||||||
addLineToFile(
|
addLineToFile(
|
||||||
startupFile,
|
startupFile,
|
||||||
`alias ${tool} "aikido-${tool}" # Safe-chain alias for ${tool}`
|
`alias ${tool} "${aikidoCommand}" # Safe-chain alias for ${tool}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,11 @@ describe("Fish shell integration", () => {
|
||||||
|
|
||||||
describe("setup", () => {
|
describe("setup", () => {
|
||||||
it("should add aliases for all provided tools", () => {
|
it("should add aliases for all provided tools", () => {
|
||||||
const tools = ["npm", "npx", "yarn"];
|
const tools = [
|
||||||
|
{ tool: "npm", aikidoCommand: "aikido-npm" },
|
||||||
|
{ tool: "npx", aikidoCommand: "aikido-npx" },
|
||||||
|
{ tool: "yarn", aikidoCommand: "aikido-yarn" }
|
||||||
|
];
|
||||||
|
|
||||||
const result = fish.setup(tools);
|
const result = fish.setup(tools);
|
||||||
assert.strictEqual(result, true);
|
assert.strictEqual(result, true);
|
||||||
|
|
@ -75,7 +79,7 @@ describe("Fish shell integration", () => {
|
||||||
// Pre-populate file with existing aliases
|
// Pre-populate file with existing aliases
|
||||||
fs.writeFileSync(mockStartupFile, 'alias npm "old-npm"\nalias npx "old-npx"\n', "utf-8");
|
fs.writeFileSync(mockStartupFile, 'alias npm "old-npm"\nalias npx "old-npx"\n', "utf-8");
|
||||||
|
|
||||||
const tools = ["npm"];
|
const tools = [{ tool: "npm", aikidoCommand: "aikido-npm" }];
|
||||||
fish.setup(tools);
|
fish.setup(tools);
|
||||||
|
|
||||||
const content = fs.readFileSync(mockStartupFile, "utf-8");
|
const content = fs.readFileSync(mockStartupFile, "utf-8");
|
||||||
|
|
@ -161,7 +165,10 @@ describe("Fish shell integration", () => {
|
||||||
|
|
||||||
describe("integration tests", () => {
|
describe("integration tests", () => {
|
||||||
it("should handle complete setup and teardown cycle", () => {
|
it("should handle complete setup and teardown cycle", () => {
|
||||||
const tools = ["npm", "yarn"];
|
const tools = [
|
||||||
|
{ tool: "npm", aikidoCommand: "aikido-npm" },
|
||||||
|
{ tool: "yarn", aikidoCommand: "aikido-yarn" }
|
||||||
|
];
|
||||||
|
|
||||||
// Setup
|
// Setup
|
||||||
fish.setup(tools);
|
fish.setup(tools);
|
||||||
|
|
@ -177,7 +184,7 @@ describe("Fish shell integration", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should handle multiple setup calls", () => {
|
it("should handle multiple setup calls", () => {
|
||||||
const tools = ["npm"];
|
const tools = [{ tool: "npm", aikidoCommand: "aikido-npm" }];
|
||||||
|
|
||||||
fish.setup(tools);
|
fish.setup(tools);
|
||||||
fish.setup(tools);
|
fish.setup(tools);
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,10 @@ function setup(tools) {
|
||||||
const startupFile = execAndGetOutput(startupFileCommand, executableName);
|
const startupFile = execAndGetOutput(startupFileCommand, executableName);
|
||||||
teardown();
|
teardown();
|
||||||
|
|
||||||
for (const tool of tools) {
|
for (const { tool, aikidoCommand } of tools) {
|
||||||
addLineToFile(
|
addLineToFile(
|
||||||
startupFile,
|
startupFile,
|
||||||
`alias ${tool}="aikido-${tool}" # Safe-chain alias for ${tool}`
|
`alias ${tool}="${aikidoCommand}" # Safe-chain alias for ${tool}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,11 @@ describe("Zsh shell integration", () => {
|
||||||
|
|
||||||
describe("setup", () => {
|
describe("setup", () => {
|
||||||
it("should add aliases for all provided tools", () => {
|
it("should add aliases for all provided tools", () => {
|
||||||
const tools = ["npm", "npx", "yarn"];
|
const tools = [
|
||||||
|
{ tool: "npm", aikidoCommand: "aikido-npm" },
|
||||||
|
{ tool: "npx", aikidoCommand: "aikido-npx" },
|
||||||
|
{ tool: "yarn", aikidoCommand: "aikido-yarn" }
|
||||||
|
];
|
||||||
|
|
||||||
const result = zsh.setup(tools);
|
const result = zsh.setup(tools);
|
||||||
assert.strictEqual(result, true);
|
assert.strictEqual(result, true);
|
||||||
|
|
@ -85,7 +89,7 @@ describe("Zsh shell integration", () => {
|
||||||
"utf-8"
|
"utf-8"
|
||||||
);
|
);
|
||||||
|
|
||||||
const tools = ["npm"];
|
const tools = [{ tool: "npm", aikidoCommand: "aikido-npm" }];
|
||||||
zsh.setup(tools);
|
zsh.setup(tools);
|
||||||
|
|
||||||
const content = fs.readFileSync(mockStartupFile, "utf-8");
|
const content = fs.readFileSync(mockStartupFile, "utf-8");
|
||||||
|
|
@ -171,7 +175,10 @@ describe("Zsh shell integration", () => {
|
||||||
|
|
||||||
describe("integration tests", () => {
|
describe("integration tests", () => {
|
||||||
it("should handle complete setup and teardown cycle", () => {
|
it("should handle complete setup and teardown cycle", () => {
|
||||||
const tools = ["npm", "yarn"];
|
const tools = [
|
||||||
|
{ tool: "npm", aikidoCommand: "aikido-npm" },
|
||||||
|
{ tool: "yarn", aikidoCommand: "aikido-yarn" }
|
||||||
|
];
|
||||||
|
|
||||||
// Setup
|
// Setup
|
||||||
zsh.setup(tools);
|
zsh.setup(tools);
|
||||||
|
|
@ -187,7 +194,7 @@ describe("Zsh shell integration", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should handle multiple setup calls", () => {
|
it("should handle multiple setup calls", () => {
|
||||||
const tools = ["npm"];
|
const tools = [{ tool: "npm", aikidoCommand: "aikido-npm" }];
|
||||||
|
|
||||||
zsh.setup(tools);
|
zsh.setup(tools);
|
||||||
zsh.setup(tools);
|
zsh.setup(tools);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue