test(handler): add unit tests for groups.go - #1602
Draft
damnnmanyaa wants to merge 1 commit into
Draft
Conversation
Signed-off-by: Manya <174072426+damnnmanyaa@users.noreply.github.com>
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.
Addresses #1581, scoped to groups.go
What's covered
Unit tests for all 11 exported handler functions in
backend/pkg/handler/groups.go, usinghttptest+echo.Contextagainst a real seeded Postgres database viaapi.NewForTestmatching the existing pattern already established in this codebase (backend/pkg/api/metrics_test.go).Each handler is covered for:
Note for reviewers: nonexistent group IDs on aggregate endpoints
The group aggregate endpoints currently return
200with empty data when given a syntactically valid but nonexistent group ID :-GET .../version_timelineGET .../status_timelineGET .../version_breakdownThese handlers query aggregate data tables directly rather than resolving the group first (unlike
GetGroup,UpdateGroup, andDeleteGroup, which query thegroupstable viadbreads.Queries.GetGroupand 404 onsql.ErrNoRows). As a result, a nonexistent group with no matching instance or status-history rows is currently indistinguishable from anexisting group that simply has no data yet.
This is out of scope for this test-coverage PR. The tests reflect actual current behavior rather than assuming what it should be. Happy to open a follow-up issue if maintainers think this is worth addressing, or to leave it as intentional empty-aggregate semantics if that's by design.
Next steps
Plan is to extend this same pattern to the other handler files (
channels.go,packages.go, etc.) in follow-up PRs once this one is reviewed.