mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-03-30 13:43:26 +08:00
test: cover cleanupAliases save failure, setAlias save failure, and validate-commands statSync catch
Round 73: Add 3 tests for genuine untested code paths: - session-aliases cleanupAliases returns failure when save blocked after removing aliases - session-aliases setAlias returns failure when save blocked on new alias creation - validate-commands silently skips broken symlinks in skill directory scanning
This commit is contained in:
@@ -1960,6 +1960,37 @@ function runTests() {
|
||||
cleanupTestDir(testDir);
|
||||
})) passed++; else failed++;
|
||||
|
||||
// ── Round 73: validate-commands.js skill directory statSync catch ──
|
||||
console.log('\nRound 73: validate-commands.js (unreadable skill entry — statSync catch):');
|
||||
|
||||
if (test('skips unreadable skill directory entries without error (broken symlink)', () => {
|
||||
const testDir = createTestDir();
|
||||
const agentsDir = createTestDir();
|
||||
const skillsDir = createTestDir();
|
||||
|
||||
// Create one valid skill directory and one broken symlink
|
||||
const validSkill = path.join(skillsDir, 'valid-skill');
|
||||
fs.mkdirSync(validSkill, { recursive: true });
|
||||
// Broken symlink: target does not exist — statSync will throw ENOENT
|
||||
const brokenLink = path.join(skillsDir, 'broken-skill');
|
||||
fs.symlinkSync('/nonexistent/target/path', brokenLink);
|
||||
|
||||
// Command that references the valid skill (should resolve)
|
||||
fs.writeFileSync(path.join(testDir, 'cmd.md'),
|
||||
'# Command\nSee skills/valid-skill/ for details.');
|
||||
|
||||
const result = runValidatorWithDirs('validate-commands', {
|
||||
COMMANDS_DIR: testDir, AGENTS_DIR: agentsDir, SKILLS_DIR: skillsDir
|
||||
});
|
||||
assert.strictEqual(result.code, 0,
|
||||
'Should pass — broken symlink in skills dir should be skipped silently');
|
||||
// The broken-skill should NOT be in validSkills, so referencing it would warn
|
||||
// but the valid-skill reference should resolve fine
|
||||
cleanupTestDir(testDir);
|
||||
cleanupTestDir(agentsDir);
|
||||
fs.rmSync(skillsDir, { recursive: true, force: true });
|
||||
})) passed++; else failed++;
|
||||
|
||||
// Summary
|
||||
console.log(`\nResults: Passed: ${passed}, Failed: ${failed}`);
|
||||
process.exit(failed > 0 ? 1 : 0);
|
||||
|
||||
Reference in New Issue
Block a user