Files
cleveragents-core/features/skill_service_coverage_boost.feature
freemo 051ee7c290
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 21s
CI / quality (pull_request) Successful in 31s
CI / typecheck (pull_request) Successful in 47s
CI / security (pull_request) Successful in 52s
CI / build (pull_request) Successful in 56s
CI / e2e_tests (pull_request) Successful in 5m1s
CI / integration_tests (pull_request) Successful in 5m30s
CI / unit_tests (pull_request) Successful in 5m42s
CI / docker (pull_request) Successful in 58s
CI / coverage (pull_request) Successful in 7m35s
CI / build (push) Successful in 21s
CI / docker (push) Has been skipped
CI / benchmark-regression (pull_request) Failing after 49m24s
CI / lint (push) Successful in 22s
CI / quality (push) Successful in 39s
CI / security (push) Successful in 48s
CI / typecheck (push) Successful in 1m26s
CI / benchmark-regression (push) Has been skipped
CI / e2e_tests (push) Successful in 5m53s
CI / coverage (push) Successful in 9m4s
CI / benchmark-publish (push) Successful in 19m10s
CI / integration_tests (push) Failing after 19m18s
CI / unit_tests (push) Failing after 19m20s
test(coverage): add Behave BDD tests to improve coverage across 52 source files
Added 52 new .feature files and corresponding _steps.py files targeting
previously uncovered code paths in the following areas:

- TUI layer: app, commands, persona (state/schema/registry), widgets,
  input (shell_exec, reference_parser)
- Application services: plan lifecycle/service/executor, session,
  project, repo indexing, correction, checkpoint, actor, llm_actors,
  strategy coordinator, resource file watcher, service retry wiring
- CLI commands: session, resource, repl, plan, db, automation_profile
- Domain models: retry_policy, resource_type, cost_budget,
  docker_compose_analyzer, detail_level, _sql_string_aware,
  _postgresql_helpers
- Core: circuit_breaker, retry_service_patterns
- Infrastructure: repositories, transaction_sandbox, strategy_registry,
  plugins/loader, container
- Config: settings
- Agents: plan_generation, context_analysis, auto_debug
- A2A: facade

All new tests follow the Behave/Gherkin BDD standard. Resolved step
definition collisions with unique prefixes. Fixed Alembic fileConfig
logger disabling issue (disable_existing_loggers=False).

ISSUES CLOSED: #1068
2026-03-20 21:22:10 +00:00

112 lines
7.1 KiB
Gherkin

@phase1 @domain @skill_service_coverage
Feature: SkillService uncovered code paths
As a developer maintaining the SkillService
I want comprehensive test coverage for defensive guards, exception
handling in database persistence, and the update-persist path
So that edge cases and failure modes are verified
#
# add_skill: None config guard (line 95)
#
@ssc_none_config
Scenario: add_skill raises ValueError when config is None
Given a skill service without persistence
When I call add_skill with a None config
Then a ssc ValueError should be raised with message "config cannot be None"
# ────────────────────────────────────────────────────────
# _load_from_db: early return when repo is None (line 278)
# ────────────────────────────────────────────────────────
@ssc_load_no_repo
Scenario: _load_from_db returns immediately when no repo is set
Given a skill service without persistence
When I explicitly call _load_from_db
Then the skills cache should remain empty
And no ssc error should be raised
# ────────────────────────────────────────────────────────
# _load_from_db: exception handling (lines 287-288)
# ────────────────────────────────────────────────────────
@ssc_load_db_error
Scenario: _load_from_db logs warning when list_all raises an exception
Given a mock skill repo that raises on list_all
When I create a skill service with the failing repo
Then the skills cache should remain empty
And a warning about failed database load should be logged
# ────────────────────────────────────────────────────────
# _persist_skill: update path (line 298)
# ────────────────────────────────────────────────────────
@ssc_persist_update
Scenario: Updating an existing skill calls repo.update instead of repo.create
Given a skill service with a mock repo and session factory
And I add a skill "local/update-target" via config
When I update the skill "local/update-target" via add_skill with update flag
Then the mock repo update method should have been called
And the mock repo create method should have been called once
# ────────────────────────────────────────────────────────
# _persist_skill: exception handling on create (lines 300-304)
# ────────────────────────────────────────────────────────
@ssc_persist_create_error
Scenario: _persist_skill logs warning when repo.create raises
Given a mock skill repo that raises on create
And a skill service with the failing-create repo
When I add a skill "local/fail-persist" via config ignoring persist errors
Then the skill should still be in the in-memory cache
And a warning about failed persist should be logged
# ────────────────────────────────────────────────────────
# _persist_skill: exception handling on update (lines 300-304)
# ────────────────────────────────────────────────────────
@ssc_persist_update_error
Scenario: _persist_skill logs warning when repo.update raises
Given a mock skill repo that raises on update
And a skill service with the failing-update repo
And I add a new skill "local/upd-fail" to the service
When I update skill "local/upd-fail" with update flag ignoring persist errors
Then the updated skill should be in the in-memory cache
And a warning about failed persist on update should be logged
# ────────────────────────────────────────────────────────
# _delete_skill_from_db: exception handling (lines 314-318)
# ────────────────────────────────────────────────────────
@ssc_delete_db_error
Scenario: _delete_skill_from_db logs warning when repo.delete raises
Given a mock skill repo that raises on delete
And a skill service with the failing-delete repo
And I add a skill "local/del-fail" to the failing-delete service
When I remove skill "local/del-fail" from the service
Then the skill should be removed from the in-memory cache
And a warning about failed database delete should be logged
# ────────────────────────────────────────────────────────
# _commit: early return when no session_factory (line 324)
# ────────────────────────────────────────────────────────
@ssc_commit_no_session
Scenario: _commit returns early when session_factory is None
Given a skill service with a mock repo but no session factory
When I add a skill "local/no-session" via config on the no-session service
Then the skill should be in the no-session service cache
And no ssc error should be raised
# ────────────────────────────────────────────────────────
# _commit: exception handling (lines 328-329)
# ────────────────────────────────────────────────────────
@ssc_commit_error
Scenario: _commit logs warning when session.commit raises
Given sscb a mock session factory that raises on commit
And a skill service with a mock repo and the failing session factory
When I add a skill "local/commit-fail" via config on the failing-commit service
Then the skill should be in the failing-commit service cache
And a warning about failed session commit should be logged