test(cleanup): Add repository unit tests - #10
Merged
Conversation
- Add comprehensive unit tests for cleanup repository - Test all CRUD operations: CreateJob, GetJob, UpdateJob, ListJobs, DeleteJob - Test job statistics operations: GetJobStats, UpdateJobStats - Use pgxmock for database mocking - Modify repository to accept DBPool interface for testability - Add pgxmock/v4 dependency - All 14 repository tests passing Coverage: - CreateJob: success and error cases - GetJob: success and not found cases - UpdateJob: success and not found cases - ListJobs: with filters and empty results - DeleteJob: success and not found cases - GetJobStats: success and not found (returns empty stats) - UpdateJobStats: success and error cases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds comprehensive unit tests for the cleanup repository layer, covering all CRUD operations and statistics management.
Changes Made
1. Repository Tests (
backend/internal/cleanup/repository_test.go- 428 lines)2. Repository Interface Update (
backend/internal/cleanup/repository.go)DBPoolinterface for database operationsDBPoolinstead of*pgxpool.Pool3. Dependencies (
go.mod,go.sum)github.com/pashagolub/pgxmock/v4 v4.9.0github.com/jackc/pgx/v5to v5.7.4Testing Performed
✅ All 14 repository unit tests passing
Test Coverage Details
CreateJob
GetJob
UpdateJob
ListJobs
DeleteJob
GetJobStats
UpdateJobStats
Breaking Changes
None - this is purely additive test coverage.
Dependencies Added
pgxmock/v4- PostgreSQL mock for unit testingChecklist
Related Issues
Part of cleanup feature test coverage initiative.
Follows PR #8 (cleanupStore tests) and PR #9 (UI component tests).
Next Steps