()
| 69 | } |
| 70 | |
| 71 | function runTests() { |
| 72 | console.log('\n=== Testing agent-data-home.js ===\n'); |
| 73 | let passed = 0; |
| 74 | let failed = 0; |
| 75 | |
| 76 | if (test('defaults to ~/.claude outside Cursor (isolated cwd)', () => { |
| 77 | withIsolatedCwd(() => { |
| 78 | withEnv({ |
| 79 | ECC_AGENT_DATA_HOME: undefined, |
| 80 | CURSOR_VERSION: undefined, |
| 81 | CURSOR_PROJECT_DIR: undefined, |
| 82 | }, () => { |
| 83 | const agentDataHome = require('../../scripts/lib/agent-data-home'); |
| 84 | const home = os.homedir(); |
| 85 | assert.strictEqual( |
| 86 | agentDataHome.resolveAgentDataHome(), |
| 87 | path.join(home, '.claude') |
| 88 | ); |
| 89 | }); |
| 90 | }); |
| 91 | })) passed++; else failed++; |
| 92 | |
| 93 | if (test('resolveAgentDataHome uses projectDir + .cursor/ecc-agent-data.json', () => { |
| 94 | const projectDir = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-agent-data-home-project-')); |
| 95 | const cursorDir = path.join(projectDir, '.cursor'); |
| 96 | fs.mkdirSync(cursorDir, { recursive: true }); |
| 97 | fs.writeFileSync( |
| 98 | path.join(cursorDir, 'ecc-agent-data.json'), |
| 99 | JSON.stringify({ agentDataHome: '~/.cursor/ecc' }), |
| 100 | 'utf8' |
| 101 | ); |
| 102 | |
| 103 | try { |
| 104 | withIsolatedCwd(() => { |
| 105 | withEnv({ |
| 106 | ECC_AGENT_DATA_HOME: undefined, |
| 107 | CURSOR_VERSION: undefined, |
| 108 | CURSOR_PROJECT_DIR: undefined, |
| 109 | }, () => { |
| 110 | const agentDataHome = require('../../scripts/lib/agent-data-home'); |
| 111 | assert.strictEqual( |
| 112 | agentDataHome.resolveAgentDataHome({ projectDir }), |
| 113 | path.join(os.homedir(), '.cursor', 'ecc') |
| 114 | ); |
| 115 | }); |
| 116 | }); |
| 117 | } finally { |
| 118 | fs.rmSync(projectDir, { recursive: true, force: true }); |
| 119 | } |
| 120 | })) passed++; else failed++; |
| 121 | |
| 122 | if (test('defaults to ~/.cursor/ecc in Cursor hook runtime (isolated cwd)', () => { |
| 123 | withIsolatedCwd(() => { |
| 124 | withEnv({ |
| 125 | ECC_AGENT_DATA_HOME: undefined, |
| 126 | CURSOR_VERSION: '1.0.0', |
| 127 | CURSOR_PROJECT_DIR: undefined, |
| 128 | }, () => { |
no test coverage detected