mirror of
https://github.com/affaan-m/ECC.git
synced 2026-09-08 02:37:55 +02:00
test(opencode): cover legacy migration boundaries
This commit is contained in:
@@ -43,6 +43,7 @@ All three changed core modules exceeded the 80 percent line target:
|
||||
| `scripts/lib/multi-harness-setup.js` | 88.75% | 82.75% | 74.01% |
|
||||
| `scripts/lib/install/claude-skill-migration.js` | 95.20% | 100% | 88.78% |
|
||||
| `scripts/lib/install-targets/opencode-home.js` | 86.66% | 100% | 78.94% |
|
||||
| `scripts/lib/install/opencode-legacy-migration.js` | 82.24% | 100% | 68.29% |
|
||||
|
||||
Coverage commands used `c8 --check-coverage --lines 80` against the corresponding focused test files.
|
||||
|
||||
|
||||
@@ -15,6 +15,11 @@ const {
|
||||
uninstallInstalledStates,
|
||||
} = require('../../scripts/lib/install-lifecycle');
|
||||
const { createInstallState, writeInstallState } = require('../../scripts/lib/install-state');
|
||||
const {
|
||||
cleanupLegacyOpencodeInstall,
|
||||
getLegacyOpencodeLocation,
|
||||
inspectLegacyOpencodeState,
|
||||
} = require('../../scripts/lib/install/opencode-legacy-migration');
|
||||
|
||||
const REPO_ROOT = path.join(__dirname, '..', '..');
|
||||
const SOURCE_RELATIVE_PATH = path.join('skills', 'skill-comply', 'SKILL.md');
|
||||
@@ -94,6 +99,35 @@ function canonicalPlan(homeDir) {
|
||||
|
||||
console.log('\n=== Testing OpenCode legacy migration ===\n');
|
||||
|
||||
test('legacy inspection distinguishes absent, invalid, and unreadable state', () => {
|
||||
const homeDir = fs.mkdtempSync(path.join(os.tmpdir(), 'opencode-legacy-inspect-'));
|
||||
try {
|
||||
const location = getLegacyOpencodeLocation(homeDir);
|
||||
assert.strictEqual(inspectLegacyOpencodeState(null).status, 'absent');
|
||||
assert.strictEqual(inspectLegacyOpencodeState(location).status, 'absent');
|
||||
|
||||
fs.mkdirSync(location.targetRoot, { recursive: true });
|
||||
fs.mkdirSync(location.installStatePath);
|
||||
assert.strictEqual(inspectLegacyOpencodeState(location).status, 'invalid');
|
||||
fs.rmSync(location.installStatePath, { recursive: true, force: true });
|
||||
|
||||
fs.writeFileSync(location.installStatePath, '{not-json', 'utf8');
|
||||
const unreadable = inspectLegacyOpencodeState(location);
|
||||
assert.strictEqual(unreadable.status, 'unreadable');
|
||||
assert.ok(unreadable.error.includes(location.installStatePath));
|
||||
|
||||
assert.deepStrictEqual(cleanupLegacyOpencodeInstall(null), {
|
||||
detected: false,
|
||||
complete: false,
|
||||
removedPaths: [],
|
||||
retainedPaths: [],
|
||||
warnings: [],
|
||||
});
|
||||
} finally {
|
||||
fs.rmSync(homeDir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test('discovery and doctor surface the legacy managed root', () => {
|
||||
const homeDir = fs.mkdtempSync(path.join(os.tmpdir(), 'opencode-legacy-discover-'));
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user