test: add unit tests for pkg/graph context helpers#213
Open
mason5052 wants to merge 1 commit intovxcontrol:masterfrom
Open
test: add unit tests for pkg/graph context helpers#213mason5052 wants to merge 1 commit intovxcontrol:masterfrom
mason5052 wants to merge 1 commit intovxcontrol:masterfrom
Conversation
Add context_test.go with 20 tests covering GetUserID, SetUserID, GetUserType, SetUserType, GetUserPermissions, SetUserPermissions, validateUserType, and validatePermission. Includes table-driven tests for validation functions and wrong-type assertion checks.
There was a problem hiding this comment.
Pull request overview
Adds unit test coverage for backend/pkg/graph/context.go context helper functions used across the graph layer (user ID, user type, permissions), addressing previously missing coverage.
Changes:
- Introduces
context_test.gowith focused tests forGet/SetUserID,Get/SetUserType, andGet/SetUserPermissions - Adds table-driven tests for internal authorization helpers
validateUserTypeandvalidatePermission
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+97
to
+103
| tests := []struct { | ||
| name string | ||
| ctx context.Context | ||
| allowed []string | ||
| wantOK bool | ||
| wantErr string | ||
| }{ |
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/graph/context.goprovides key context helper functions used throughout the graph layer (user ID, user type, permissions) but had no unit test coverage.Solution
Add
context_test.gowith 20 focused unit tests covering all testable functions in the package.Closes N/A
Type of Change
Areas Affected
Testing and Verification
Test Configuration
Test Steps
go test ./pkg/graph/... -count=1go test ./pkg/graph/... -count=1 -shuffle=ongo vet ./pkg/graph/...Test Results
Security Considerations
No security implications. Test-only change covering authentication context helpers.
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
Additional Notes
validatePermissionWithFlowIDis intentionally excluded: it requires adatabase.Querierinterface, which would need either a large mock or integration test infrastructure outside the scope of this narrow PR.