test: add unit tests for pkg/server/context helpers#214
Open
mason5052 wants to merge 1 commit intovxcontrol:masterfrom
Open
test: add unit tests for pkg/server/context helpers#214mason5052 wants to merge 1 commit intovxcontrol:masterfrom
mason5052 wants to merge 1 commit intovxcontrol:masterfrom
Conversation
Add context_test.go with 15 tests covering GetInt64, GetUint64, GetString, GetStringArray, and GetStringFromSession. Each function has table-driven subtests for found, missing, and wrong-type cases. Session tests use gin-contrib/sessions/cookie with httptest.
There was a problem hiding this comment.
Pull request overview
Adds a new Go test suite for the backend/pkg/server/context helper functions that extract typed values from a Gin context and session.
Changes:
- Introduces table-driven tests for
GetInt64,GetUint64,GetString, andGetStringArray. - Adds an integration-style test for
GetStringFromSessionusinggin-contrib/sessionswith a cookie store.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Description of the Change
Problem
backend/pkg/server/context/context.goprovides typed getter functions used across the server layer but had no unit test coverage.Solution
Add
context_test.gowith 15 table-driven unit tests covering all 5 exported functions:GetInt64,GetUint64,GetString,GetStringArray, andGetStringFromSession. Each function has three subtests: found, missing, and wrong-type cases.Session tests use
gin-contrib/sessions/cookiewithhttptestfor a realistic but minimal setup.Closes N/A
Type of Change
Areas Affected
Testing and Verification
Test Configuration
Test Steps
gofmt -w pkg/server/context/context_test.gogo test ./pkg/server/context/... -count=1 -vgo test ./pkg/server/context/... -count=1 -shuffle=ongo vet ./pkg/server/context/...Test Results
Security Considerations
No security implications. Test-only change.
Performance Impact
None. Test-only change.
Documentation Updates
None required.
Deployment Notes
None. Test-only change.
Checklist
Code Quality
go fmtandgo vet(for Go code)Security
Compatibility
Documentation