mirror of
https://github.com/dtzp555-max/ocp.git
synced 2026-07-19 09:44:07 +00:00
feat(doctor): --check oauth fast path (#93)
* feat(doctor): --check oauth fast path Implements the --check oauth fast path documented in cmd_doctor_help but previously unimplemented. Skips version detection, from-version check, git operations, and models endpoint — runs only the curl against /health + auth.ok extraction. Use cases: - After `claude auth login`, fast verify OCP can spawn cli.js - After a known service blip, quick health gate before larger ops - AI agent's setup-repair loop: ./ocp doctor --check oauth in a retry-after-fix step 3 unit tests cover: PASS path, OAuth FAIL → fix_oauth, service down → fix_service. No cli.js citation needed: this is OCP-internal doctor logic with no corresponding cli.js operation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * chore(doctor): nit fixes for --check oauth (N3 body=null test + N4 skipped sentinel comment) --------- Co-authored-by: dtzp555 <dtzp555@gmail.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -843,6 +843,57 @@ test("rollback latest snapshot restores files (mockExec)", async () => {
|
||||
assert.ok(result.phases.some(p => p.name === "git-checkout"));
|
||||
});
|
||||
|
||||
// ── Doctor --check oauth fast path tests ──
|
||||
console.log("\nDoctor --check oauth:");
|
||||
|
||||
await asyncTest("doctor --check oauth runs only oauth check (skips version/from-version)", async () => {
|
||||
const result = await runDoctor({
|
||||
checkOnly: "oauth",
|
||||
mockVersion: "v3.10.0",
|
||||
mockLatest: "v3.14.0",
|
||||
mockHealth: { status: 200, body: { auth: { ok: true, message: "authenticated" } } }
|
||||
});
|
||||
// Should still produce a valid result object
|
||||
assert.equal(result.schema_version, "1");
|
||||
// checks[] should only contain oauth_ok (no current_version, no from_version_supported)
|
||||
const ids = result.checks.map(c => c.id);
|
||||
assert.deepEqual(ids, ["oauth_ok"]);
|
||||
assert.equal(result.next_action.kind, "noop");
|
||||
});
|
||||
|
||||
await asyncTest("doctor --check oauth + OAuth FAIL → fix_oauth", async () => {
|
||||
const result = await runDoctor({
|
||||
checkOnly: "oauth",
|
||||
mockHealth: { status: 200, body: { auth: { ok: false, message: "ENOEXEC" } } }
|
||||
});
|
||||
const ids = result.checks.map(c => c.id);
|
||||
assert.deepEqual(ids, ["oauth_ok"]);
|
||||
assert.equal(result.next_action.kind, "fix_oauth");
|
||||
assert.equal(result.fail_count, 1);
|
||||
});
|
||||
|
||||
await asyncTest("doctor --check oauth + service down → fix_service", async () => {
|
||||
const result = await runDoctor({
|
||||
checkOnly: "oauth",
|
||||
mockHealth: { error: "ECONNREFUSED" }
|
||||
});
|
||||
const ids = result.checks.map(c => c.id);
|
||||
assert.deepEqual(ids, ["oauth_ok"]);
|
||||
assert.equal(result.next_action.kind, "fix_service");
|
||||
assert.equal(result.fail_count, 1);
|
||||
});
|
||||
|
||||
await asyncTest("doctor --check oauth + 200 with null body → fix_service", async () => {
|
||||
const result = await runDoctor({
|
||||
checkOnly: "oauth",
|
||||
mockHealth: { status: 200, body: null }
|
||||
});
|
||||
const ids = result.checks.map(c => c.id);
|
||||
assert.deepEqual(ids, ["oauth_ok"]);
|
||||
assert.equal(result.next_action.kind, "fix_service");
|
||||
assert.equal(result.fail_count, 1);
|
||||
});
|
||||
|
||||
// ── Cleanup ──
|
||||
closeDb();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user