Files
cleveragents-core/features/resource_cli_coverage_boost.feature
T

71 lines
3.5 KiB
Gherkin

Feature: Resource CLI coverage boost for remaining uncovered lines
As a developer
I want edge-case paths in resource.py thoroughly tested
So that the line-rate and branch-rate improve beyond 0.93 / 0.88
# ---- _get_registry_service (lines 79-81) ----
Scenario: _get_registry_service delegates to the DI container
Given the DI container is mocked for resource registry
When _get_registry_service is called directly
Then the returned service should be the mock registry service
# ---- type_add --update re-raises ValidationError (line 181) ----
Scenario: type_add --update re-raises ValidationError whose message lacks "already exists"
Given a mock resource service that raises a non-already-exists ValidationError on register_type
When I invoke type add with update flag via CliRunner
Then the CliRunner exit code should be non-zero
And the CliRunner output should contain "Validation error"
# ---- type_add FileNotFoundError (lines 193-195) ----
Scenario: type_add catches FileNotFoundError from service
Given a mock resource service that raises FileNotFoundError on register_type
When I invoke type add with a dummy config via CliRunner
Then the CliRunner exit code should be non-zero
And the CliRunner output should contain "Config file not found"
# ---- type_remove confirm declined (lines 234-236) ----
Scenario: type_remove aborts when user declines confirmation prompt
Given a mock resource service with a removable custom type
When I invoke type remove without --yes and answer no via CliRunner
Then the CliRunner exit code should be non-zero
And the CliRunner output should contain "Aborted"
# ---- type_remove NotFoundError from service (lines 263-265) ----
Scenario: type_remove aborts when service.remove_type raises NotFoundError
Given a mock resource service whose remove_type raises NotFoundError
When I invoke type remove with --yes via CliRunner for the phantom type
Then the CliRunner exit code should be non-zero
And the CliRunner output should contain "Resource type not found"
# ---- type_remove ValidationError from service (lines 269-271) ----
Scenario: type_remove aborts when service.remove_type raises ValidationError
Given a mock resource service whose remove_type raises ValidationError
When I invoke type remove with --yes via CliRunner for the failing type
Then the CliRunner exit code should be non-zero
And the CliRunner output should contain "Error:"
# ---- resource_remove ValidationError bubble-up (service guard) ----
@resource_cli_guard
Scenario: resource_remove aborts when service rejects removal with ValidationError
Given a mock resource service whose remove_resource raises ValidationError for the resource
When I invoke resource remove with --yes via CliRunner for the edged resource
Then the CliRunner exit code should be non-zero
And the CliRunner output should contain "edge(s) still reference it"
# ---- resource_remove unexpected exception surfaced to CLI ----
@resource_cli_guard
Scenario: resource_remove aborts when service remove_resource raises an unexpected exception
Given a mock resource service whose remove_resource raises a generic exception for the resource
When I invoke resource remove with --yes via CliRunner for the failing resource
Then the CliRunner exit code should be non-zero
And the CliRunner output should contain "Unexpected error:"
And the mock service should have attempted to remove the resource