Files
cleveragents-core/features/database_repository_coverage.feature
T

81 lines
3.7 KiB
Gherkin

Feature: Database Repository Error Handling Coverage
As a developer
I want to ensure database repositories handle edge cases properly
So that missing entities and failed updates are handled gracefully
@phase1
Scenario: ProjectRepository get_by_id returns None for non-existent project
Given I have a project repository with database session
When I query for a project with non-existent ID 99999
Then the repository should return None for missing project
@phase1
Scenario: ProjectRepository update method handles successful project updates
Given I have a project repository with database session
And I have created a project named "test-project"
When I modify the project name to "updated-project"
Then the project should be updated in the database
And the updated_at timestamp should be refreshed
@phase1
Scenario: ProjectRepository update returns unchanged object for non-existent project
Given I have a project repository with database session
When I attempt to update a project that does not exist
Then the update operation should complete without error
And the original project object should be returned unchanged
@phase1
Scenario: PlanRepository get_current_for_project returns None when no current plan exists
Given I have a plan repository with database session
When I query for current plan of non-existent project 99999
Then the repository should return None for missing current plan
@phase1
Scenario: PlanRepository get_by_id returns plan with None build when no build exists
Given I have a plan repository with database session
And I have created a plan without build information
When I retrieve the plan by ID
Then the plan should be returned with null build field
@phase1
Scenario: ProjectRepository create raises database error on OperationalError
Given I have a project repository with a session that fails on create
When I attempt to create a project named "failing-project" with that failing session
Then a database error should be raised when creating the project
And the session rollback should be triggered for the project create failure
@phase1
Scenario: ProjectRepository get_by_id wraps OperationalError in DatabaseError
Given I have a project repository with a session that fails on query
When I query the project repository for ID 42 expecting a failure
Then a database error should be raised for the project lookup
@phase1
Scenario: PlanRepository get_by_id returns None for unknown plan
Given I have a plan repository with database session
When I query for a plan with non-existent ID 99999
Then the plan repository should return None for missing plan
@phase1
Scenario: PlanRepository update persists applied_at field when provided
Given I have a plan repository with database session
And I have created a plan without build information
When I update the plan with a new applied timestamp
Then the plan record should store the applied timestamp value
@phase1
Scenario: PlanRepository get_current returns None when no plan is marked current
Given I have a plan repository with database session
And I have created a plan without build information
When I request the current plan for the project
Then the repository should return None for missing current plan
@phase1
Scenario: ChangeRepository get_all returns persisted changes
Given I have a plan repository with database session
And I have created a plan without build information
And I have a change repository with the shared database session
And I have added a change for the plan
When I request all changes for the plan
Then the repository should include the added change