mirror of
https://github.com/ultraworkers/claw-code.git
synced 2026-05-30 03:35:20 +08:00
test(#762): classify_error_kind now covers all 23 classifier arms (was 8 of 23)
This commit is contained in:
parent
d83de563c1
commit
88ce181031
@ -7689,3 +7689,5 @@ Original filing (2026-04-18): the session emitted `SessionStart hook (completed)
|
||||
760. **`agent_not_found` and `plugin_not_found` error envelopes lacked `hint` field** — dogfooded 2026-05-26 on `ef31328a`. `claw agents show nonexistent-agent --output-format json` returned `error_kind:"agent_not_found"` with `hint: null`; same for `claw plugins show`. Both structured JSON envelopes in `commands/src/lib.rs` and `main.rs` omitted `hint`. Fix: added `"hint": "Run \`claw agents list\` to see available agents."` to the `agent_not_found` envelope; `"hint": "Run \`claw plugins list\` to see available plugins."` to the `plugin_not_found` envelope. Source: Jobdori dogfood sweep on `ef31328a`, 2026-05-26.
|
||||
|
||||
761. **`mcp show <nonexistent>` and `skills show <nonexistent>` returned `hint: null`** — dogfooded 2026-05-27 on `7fa81b5d`. `server_not_found` envelope in `render_mcp_show_json` and `skill_not_found` envelope in `print_skills` JSON path both lacked `hint` fields, unlike `agent_not_found`/`plugin_not_found` fixed in #760. Fix: added `"hint": "Run \`claw mcp list\` to see configured servers."` to `server_not_found` and `"hint": "Run \`claw skills list\` to see available skills."` to `skill_not_found`. All four `*_not_found` envelopes now have hints. Source: Jobdori dogfood sweep on `7fa81b5d`, 2026-05-27.
|
||||
|
||||
762. **`classify_error_kind` unit test missing coverage for 15 of 23 classifier arms** — dogfooded 2026-05-27 on `d83de563`. `classify_error_kind_returns_correct_discriminants` only asserted 8 of the 23 arms, leaving `missing_flag_value`, `invalid_flag_value`, `missing_prompt`, `interactive_only`, `unknown_agents_subcommand`, `agent_not_found`, `plugin_not_found`, `skill_not_found`, `unsupported_config_section`, `no_managed_sessions`, `legacy_session_no_workspace_binding`, `missing_manifests`, `unknown_plugins_action`, `unsupported_skills_action`, and `confirmation_required` uncovered. Any discriminant string drift would silently fall to `"unknown"` without a failing test. Fix: added 18 new `assert_eq!` invocations covering all previously untested arms. Source: Jobdori test-brittleness sweep on `d83de563`, 2026-05-27.
|
||||
|
||||
@ -12833,6 +12833,88 @@ mod tests {
|
||||
classify_error_kind("something completely unknown"),
|
||||
"unknown"
|
||||
);
|
||||
// #762: coverage for all classifier arms added since #77 — prevents silent fallback
|
||||
// to "unknown" if discriminant strings drift.
|
||||
assert_eq!(
|
||||
classify_error_kind("Manifest source files are missing: /tmp/x"),
|
||||
"missing_manifests"
|
||||
);
|
||||
assert_eq!(
|
||||
classify_error_kind("no managed sessions found in /tmp"),
|
||||
"no_managed_sessions"
|
||||
);
|
||||
assert_eq!(
|
||||
classify_error_kind("legacy session is missing workspace binding"),
|
||||
"legacy_session_no_workspace_binding"
|
||||
);
|
||||
assert_eq!(
|
||||
classify_error_kind("unsupported skills action: bogus. Supported actions: list"),
|
||||
"unsupported_skills_action"
|
||||
);
|
||||
assert_eq!(
|
||||
classify_error_kind(
|
||||
"missing_flag_value: missing value for --model.\nUsage: --model <provider/model>"
|
||||
),
|
||||
"missing_flag_value"
|
||||
);
|
||||
assert_eq!(
|
||||
classify_error_kind("invalid_flag_value: unsupported permission mode 'bogus'.\nUsage: --permission-mode read-only|workspace-write|danger-full-access"),
|
||||
"invalid_flag_value"
|
||||
);
|
||||
assert_eq!(
|
||||
classify_error_kind("is not yet implemented"),
|
||||
"unsupported_command"
|
||||
);
|
||||
assert_eq!(
|
||||
classify_error_kind("confirmation required before running destructive operation"),
|
||||
"confirmation_required"
|
||||
);
|
||||
assert_eq!(
|
||||
classify_error_kind("api returned unexpected status 429"),
|
||||
"api_http_error"
|
||||
);
|
||||
assert_eq!(
|
||||
classify_error_kind("interactive_only: this command requires an interactive terminal"),
|
||||
"interactive_only"
|
||||
);
|
||||
assert_eq!(
|
||||
classify_error_kind("slash command /compact is interactive-only"),
|
||||
"interactive_only"
|
||||
);
|
||||
assert_eq!(
|
||||
classify_error_kind("unknown agents subcommand: bogus. Supported: list, show, help"),
|
||||
"unknown_agents_subcommand"
|
||||
);
|
||||
assert_eq!(
|
||||
classify_error_kind("agent not found: my-agent"),
|
||||
"agent_not_found"
|
||||
);
|
||||
assert_eq!(
|
||||
classify_error_kind("my-plugin is not installed"),
|
||||
"plugin_not_found"
|
||||
);
|
||||
assert_eq!(
|
||||
classify_error_kind("skill source /path/to/skill not found"),
|
||||
"skill_not_found"
|
||||
);
|
||||
assert_eq!(
|
||||
classify_error_kind("skill 'my-skill' does not exist"),
|
||||
"skill_not_found"
|
||||
);
|
||||
assert_eq!(
|
||||
classify_error_kind("Unsupported config section 'show'. Use: env, hooks, model"),
|
||||
"unsupported_config_section"
|
||||
);
|
||||
assert_eq!(
|
||||
classify_error_kind("unknown_plugins_action: bogus"),
|
||||
"unknown_plugins_action"
|
||||
);
|
||||
assert_eq!(
|
||||
classify_error_kind(
|
||||
"missing_prompt: -p requires a prompt string.\nUsage: claw -p <text>"
|
||||
),
|
||||
"missing_prompt"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user