mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Some cleanup
This commit is contained in:
parent
24af6f21eb
commit
b0f392522b
19 changed files with 286 additions and 8 deletions
|
|
@ -8,6 +8,7 @@ import { knownAikidoTools } from "../helpers.js";
|
|||
describe("Zsh shell integration", () => {
|
||||
let mockStartupFile;
|
||||
let zsh;
|
||||
let getSafeChainDirResult = undefined;
|
||||
|
||||
beforeEach(async () => {
|
||||
// Create temporary startup file for testing
|
||||
|
|
@ -18,6 +19,7 @@ describe("Zsh shell integration", () => {
|
|||
namedExports: {
|
||||
doesExecutableExistOnSystem: () => true,
|
||||
getScriptsDir: () => "/test-home/.safe-chain/scripts",
|
||||
getSafeChainDir: () => getSafeChainDirResult,
|
||||
addLineToFile: (filePath, line) => {
|
||||
if (!fs.existsSync(filePath)) {
|
||||
fs.writeFileSync(filePath, "", "utf-8");
|
||||
|
|
@ -53,6 +55,7 @@ describe("Zsh shell integration", () => {
|
|||
|
||||
// Reset mocks
|
||||
mock.reset();
|
||||
getSafeChainDirResult = undefined;
|
||||
});
|
||||
|
||||
describe("isInstalled", () => {
|
||||
|
|
@ -171,6 +174,40 @@ describe("Zsh shell integration", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("SAFE_CHAIN_DIR", () => {
|
||||
it("should write export line to rc file when custom dir is set", () => {
|
||||
getSafeChainDirResult = "/custom/safe-chain";
|
||||
zsh.setup();
|
||||
|
||||
const content = fs.readFileSync(mockStartupFile, "utf-8");
|
||||
assert.ok(
|
||||
content.includes('export SAFE_CHAIN_DIR="/custom/safe-chain" # Safe-chain installation directory')
|
||||
);
|
||||
});
|
||||
|
||||
it("should not write export line when no custom dir is set", () => {
|
||||
getSafeChainDirResult = undefined;
|
||||
zsh.setup();
|
||||
|
||||
const content = fs.readFileSync(mockStartupFile, "utf-8");
|
||||
assert.ok(!content.includes("SAFE_CHAIN_DIR"));
|
||||
});
|
||||
|
||||
it("should remove export line on teardown", () => {
|
||||
const initialContent = [
|
||||
"#!/bin/zsh",
|
||||
'export SAFE_CHAIN_DIR="/custom/safe-chain" # Safe-chain installation directory',
|
||||
"source /test-home/.safe-chain/scripts/init-posix.sh # Safe-chain Zsh initialization script",
|
||||
].join("\n");
|
||||
|
||||
fs.writeFileSync(mockStartupFile, initialContent, "utf-8");
|
||||
|
||||
zsh.teardown(knownAikidoTools);
|
||||
const content = fs.readFileSync(mockStartupFile, "utf-8");
|
||||
assert.ok(!content.includes("SAFE_CHAIN_DIR"));
|
||||
});
|
||||
});
|
||||
|
||||
describe("integration tests", () => {
|
||||
it("should handle complete setup and teardown cycle", () => {
|
||||
const tools = [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue