Files
cleveragents-core/features/skill_repo_coverage.feature
T
2026-02-21 16:30:40 +00:00

186 lines
10 KiB
Gherkin
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
@phase1 @domain @repository @skill_repo_coverage
Feature: Skill Repository Coverage Uncovered Lines
As a developer maintaining the skill registry
I want all repository error handlers and conditional branches fully tested
So that database failures and edge-case data paths are exercised
# ===========================================================================
# SkillInUseError constructor (lines 4027-4031)
# ===========================================================================
@srcover_error_class
Scenario: SkillInUseError stores name and message without detail
When a SkillInUseError is created for skill "local/my-skill" without detail
Then the SkillInUseError message should contain "local/my-skill"
And the SkillInUseError skill_name should be "local/my-skill"
@srcover_error_class
Scenario: SkillInUseError stores name and detail in message
When a SkillInUseError is created for skill "local/busy" with detail "3 plans active"
Then the SkillInUseError message should contain "local/busy"
And the SkillInUseError message should contain "3 plans active"
And the SkillInUseError skill_name should be "local/busy"
# ===========================================================================
# ToolRepository.__init__ TypeError guard (line 3387)
# ===========================================================================
@srcover_tool_init
Scenario: ToolRepository without session factory raises TypeError
When a ToolRepository is created without any session factory
Then a TypeError should be raised about session_factory requirement
# ===========================================================================
# ToolRepository._extract_value enum unwrapping (line 3410)
# ===========================================================================
@srcover_extract_value
Scenario: ToolRepository extracts value from enum-like object
When _extract_value is called with an enum-like attribute having value "active"
Then the extracted value should be "active"
# ===========================================================================
# ToolRepository.remove success return path (line 3514)
# ===========================================================================
@srcover_tool_remove
Scenario: ToolRepository.remove returns True for existing tool
Given a tool repository with a real in-memory database for srcover
And a tool "test/removable" exists in the srcover tool repository
When the tool "test/removable" is removed via srcover repository
Then the srcover tool removal result should be True
# ===========================================================================
# ValidationAttachmentRepository.create with non-None args (line 3589)
# ===========================================================================
@srcover_val_args
Scenario: ValidationAttachment created with args serialises JSON
Given a validation attachment repository with real database for srcover
When a validation is attached with args {"retries": 3, "timeout": 120} for srcover
Then the srcover attachment should have args_json containing "retries"
# ===========================================================================
# ValidationAttachmentRepository.get_by_id returns None (line 3714)
# ===========================================================================
@srcover_val_get_none
Scenario: ValidationAttachmentRepository.get_by_id returns None for missing ID
Given a validation attachment repository with real database for srcover
When get_by_id is called with a non-existent attachment ID for srcover
Then the srcover get_by_id result should be None
# ===========================================================================
# ValidationAttachmentRepository.get_by_id OperationalError (lines 3725-3726)
# ===========================================================================
@srcover_val_get_error
Scenario: ValidationAttachmentRepository.get_by_id raises DatabaseError on OperationalError
Given a validation attachment repository with mock session raising OperationalError for srcover
When get_by_id is called and an OperationalError occurs for srcover
Then a srcover DatabaseError should be raised containing "Failed to get attachment"
# ===========================================================================
# ResourceRepository.auto_discover_children empty child_type_name (line 2555)
# ===========================================================================
@srcover_auto_discover
Scenario: auto_discover_children skips rules with empty type name
Given a resource repository with in-memory database for srcover auto-discover
And a resource type with auto_discover rules containing an empty type for srcover
And a resource of that type exists for srcover auto-discover
When auto_discover_children is called for the srcover resource
Then the srcover auto-discover result should be an empty list
# ===========================================================================
# SkillRepository.create OperationalError handler (lines 4093-4095)
# ===========================================================================
@srcover_skill_create_error
Scenario: SkillRepository.create raises DatabaseError on OperationalError
Given a skill repository with mock session raising OperationalError on flush for srcover
When a skill is created through the srcover repository and an error is expected
Then a srcover DatabaseError should be raised containing "Failed to create skill"
# ===========================================================================
# SkillRepository.create non-UNIQUE IntegrityError (line 4090)
# ===========================================================================
@srcover_skill_create_error
Scenario: SkillRepository.create raises DatabaseError on non-UNIQUE IntegrityError
Given a skill repository with mock session raising non-UNIQUE IntegrityError for srcover
When a skill is created through the srcover repository and an error is expected
Then a srcover DatabaseError should be raised containing "Failed to create skill"
# ===========================================================================
# SkillRepository.create DuplicateSkillError re-raise (lines 4091-4092)
# ===========================================================================
@srcover_skill_create_error
Scenario: SkillRepository.create re-raises DuplicateSkillError from within try block
Given a skill repository with mock session raising DuplicateSkillError on flush for srcover
When a skill is created through the srcover repository and a duplicate error is expected
Then a srcover DuplicateSkillError should be raised
# ===========================================================================
# SkillRepository.get_by_name OperationalError handler (lines 4110-4111)
# ===========================================================================
@srcover_skill_get_error
Scenario: SkillRepository.get_by_name raises DatabaseError on OperationalError
Given a skill repository with mock session raising OperationalError on query for srcover
When a skill is fetched by name through the srcover repository and an error is expected
Then a srcover DatabaseError should be raised containing "Failed to get skill"
# ===========================================================================
# SkillRepository.list_all OperationalError handler (lines 4133-4134)
# ===========================================================================
@srcover_skill_list_error
Scenario: SkillRepository.list_all raises DatabaseError on OperationalError
Given a skill repository with mock session raising OperationalError on query for srcover
When skills are listed through the srcover repository and an error is expected
Then a srcover DatabaseError should be raised containing "Failed to list skills"
# ===========================================================================
# SkillRepository.update OperationalError handler (lines 4192-4194)
# ===========================================================================
@srcover_skill_update_error
Scenario: SkillRepository.update raises DatabaseError on OperationalError
Given a skill repository with mock session raising OperationalError on query for srcover
When a skill is updated through the srcover repository and an error is expected
Then a srcover DatabaseError should be raised containing "Failed to update skill"
# ===========================================================================
# SkillRepository.update overrides truthy + child item loop (lines 4168, 4178)
# ===========================================================================
@srcover_skill_update_overrides
Scenario: SkillRepository.update persists overrides and replaces child items
Given a clean in-memory skill repository for srcover update tests
And a skill "local/upd-test" is registered with tool refs for srcover
When the skill "local/upd-test" is updated with overrides and new items for srcover
Then the srcover updated skill should have overrides metadata
And the srcover updated skill should have the new items
# ===========================================================================
# SkillRepository.delete OperationalError handler (lines 4219-4221)
# ===========================================================================
@srcover_skill_delete_error
Scenario: SkillRepository.delete raises DatabaseError on OperationalError
Given a skill repository with mock session raising OperationalError on query for srcover
When a skill is deleted through the srcover repository and an error is expected
Then a srcover DatabaseError should be raised containing "Failed to delete skill"
# ===========================================================================
# ResourceTypeRepository.create DuplicateResourceTypeError (line 1711)
# ===========================================================================
@srcover_rt_duplicate
Scenario: ResourceTypeRepository.create raises DuplicateResourceTypeError on UNIQUE constraint
Given a resource type repository with mock session raising UNIQUE IntegrityError for srcover
When a resource type is created through the srcover repository and an error is expected
Then a srcover DuplicateResourceTypeError should be raised