forked from cleveragents/cleveragents-core
31472b5413
Add Behave feature/step pairs that exercise uncovered branches across handlers, LSP, CLI, and service layers to reach the coverage gate. ISSUES CLOSED: #1232
118 lines
5.4 KiB
Gherkin
118 lines
5.4 KiB
Gherkin
@mock_only
|
|
Feature: Plan CLI coverage round 3
|
|
Exercise uncovered lines in cleveragents/cli/commands/plan.py that are
|
|
not yet hit by existing test suites. Each scenario uses the "plcov3"
|
|
step prefix to avoid Behave AmbiguousStep collisions.
|
|
|
|
# ── validate_namespaced_actor (lines 104, 107-108) ──────────────
|
|
|
|
Scenario: validate_namespaced_actor rejects invalid actor name
|
|
Given a plcov3 CLI runner
|
|
When I plcov3 call validate_namespaced_actor with value "BAD_NAME" and flag "--strategy-actor"
|
|
Then the plcov3 error should be a ValidationError with message containing "namespace/name"
|
|
|
|
Scenario: validate_namespaced_actor accepts valid actor name
|
|
Given a plcov3 CLI runner
|
|
When I plcov3 call validate_namespaced_actor with value "openai/gpt-4" and flag "--strategy-actor"
|
|
Then the plcov3 result should equal "openai/gpt-4"
|
|
|
|
# ── _plan_spec_dict with execution_environment (line 184) ───────
|
|
|
|
Scenario: _plan_spec_dict includes execution_environment when set
|
|
Given a plcov3 CLI runner
|
|
And a plcov3 v3 plan with execution_environment "container"
|
|
When I plcov3 call _plan_spec_dict
|
|
Then the plcov3 spec dict should contain key "execution_environment" with value "container"
|
|
|
|
# ── build command PlanError handler (line 790) ──────────────────
|
|
|
|
Scenario: build command handles PlanError
|
|
Given a plcov3 CLI runner
|
|
And a plcov3 mocked build environment that raises PlanError
|
|
When I plcov3 invoke the build command
|
|
Then the plcov3 CLI output should contain "Build Error"
|
|
|
|
# ── apply command v3 path with plan_id (lines 799-824) ─────────
|
|
|
|
Scenario: apply command with plan_id delegates to v3 lifecycle
|
|
Given a plcov3 CLI runner
|
|
And a plcov3 mocked lifecycle service for apply happy path
|
|
When I plcov3 invoke apply with plan_id "PLAN-001"
|
|
Then the plcov3 CLI exit code should be 0
|
|
|
|
# ── apply command legacy path with changes (lines 826-858) ──────
|
|
|
|
Scenario: apply command legacy path with pending changes
|
|
Given a plcov3 CLI runner
|
|
And a plcov3 mocked legacy apply environment with pending changes
|
|
When I plcov3 invoke apply without plan_id
|
|
Then the plcov3 CLI output should contain "Successfully applied"
|
|
|
|
Scenario: apply command legacy path with no pending changes
|
|
Given a plcov3 CLI runner
|
|
And a plcov3 mocked legacy apply environment with no pending changes
|
|
When I plcov3 invoke apply without plan_id
|
|
Then the plcov3 CLI output should contain "No changes to apply"
|
|
|
|
# ── continue_plan command (lines 1205-1224) ─────────────────────
|
|
|
|
Scenario: continue command with prompt
|
|
Given a plcov3 CLI runner
|
|
And a plcov3 mocked continue environment
|
|
When I plcov3 invoke continue with prompt "add caching"
|
|
Then the plcov3 CLI output should contain "Added instructions"
|
|
|
|
Scenario: continue command without prompt shows current plan
|
|
Given a plcov3 CLI runner
|
|
And a plcov3 mocked continue environment with current plan
|
|
When I plcov3 invoke continue without prompt
|
|
Then the plcov3 CLI output should contain "Continuing with plan"
|
|
|
|
# ── use_action with strategy_actor (lines 1529-1542, 1631-1633, 1751-1752) ─
|
|
|
|
Scenario: use command with strategy-actor override
|
|
Given a plcov3 CLI runner
|
|
And a plcov3 mocked use_action environment
|
|
When I plcov3 invoke use with action "local/test" and strategy-actor "openai/gpt-4"
|
|
Then the plcov3 CLI exit code should be 0
|
|
|
|
# ── use_action with execution_env_priority valid (lines 1789-1792) ──
|
|
|
|
Scenario: use command with valid execution-env-priority
|
|
Given a plcov3 CLI runner
|
|
And a plcov3 mocked use_action environment
|
|
When I plcov3 invoke use with action "local/test" and execution-environment "host" and priority "fallback"
|
|
Then the plcov3 CLI exit code should be 0
|
|
|
|
# ── use_action with invalid execution_env_priority (line 1794) ──
|
|
|
|
Scenario: use command with invalid execution-env-priority
|
|
Given a plcov3 CLI runner
|
|
And a plcov3 mocked use_action environment
|
|
When I plcov3 invoke use with action "local/test" and execution-environment "host" and priority "INVALID"
|
|
Then the plcov3 CLI output should contain "Invalid execution env priority"
|
|
|
|
# ── plan diff command (lines 2740-2741, 2743) ──────────────────
|
|
|
|
Scenario: diff command invokes apply service
|
|
Given a plcov3 CLI runner
|
|
And a plcov3 mocked apply service for diff
|
|
When I plcov3 invoke diff with plan_id "PLAN-001"
|
|
Then the plcov3 CLI exit code should be 0
|
|
|
|
# ── correct_decision ValidationError handler (lines 3047-3048) ──
|
|
|
|
Scenario: correct command handles ValidationError
|
|
Given a plcov3 CLI runner
|
|
And a plcov3 mocked correction environment that raises ValidationError
|
|
When I plcov3 invoke correct with identifier "DEC-001" mode "revert" guidance "fix it"
|
|
Then the plcov3 CLI output should contain "Validation Error"
|
|
|
|
# ── correct_decision CleverAgentsError handler (line 3051) ──────
|
|
|
|
Scenario: correct command handles CleverAgentsError
|
|
Given a plcov3 CLI runner
|
|
And a plcov3 mocked correction environment that raises CleverAgentsError
|
|
When I plcov3 invoke correct with identifier "DEC-001" mode "revert" guidance "fix it"
|
|
Then the plcov3 CLI output should contain "Error"
|