[PR #213] [MERGED] test: add unit tests for pkg/graph context helpers #239

Closed
opened 2026-06-06 22:09:50 -04:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/vxcontrol/pentagi/pull/213
Author: @mason5052
Created: 3/17/2026
Status: Merged
Merged: 3/20/2026
Merged by: @asdek

Base: feature/next_releaseHead: test/graph-context-coverage


📝 Commits (1)

  • b130cd0 test: add graph context helper coverage

📊 Changes

1 file changed (+200 additions, -0 deletions)

View changed files

backend/pkg/graph/context_test.go (+200 -0)

📄 Description

Description of the Change

Problem

backend/pkg/graph/context.go provides key context helper functions used throughout the graph layer (user ID, user type, permissions) but had no unit test coverage.

Solution

Add context_test.go with 20 focused unit tests covering all testable functions in the package.

Closes N/A

Type of Change

  • 🧪 Test update

Areas Affected

  • Core Services (Frontend UI/Backend API)

Testing and Verification

Test Configuration

os: linux
go: 1.24.1

Test Steps

  1. go test ./pkg/graph/... -count=1
  2. go test ./pkg/graph/... -count=1 -shuffle=on
  3. go vet ./pkg/graph/...

Test Results

=== RUN   TestGetUserID_Found
--- PASS: TestGetUserID_Found (0.00s)
=== RUN   TestGetUserID_Missing
--- PASS: TestGetUserID_Missing (0.00s)
=== RUN   TestGetUserID_WrongType
--- PASS: TestGetUserID_WrongType (0.00s)
=== RUN   TestSetUserID_Roundtrip
--- PASS: TestSetUserID_Roundtrip (0.00s)
=== RUN   TestGetUserType_Found
--- PASS: TestGetUserType_Found (0.00s)
=== RUN   TestGetUserType_Missing
--- PASS: TestGetUserType_Missing (0.00s)
=== RUN   TestGetUserType_WrongType
--- PASS: TestGetUserType_WrongType (0.00s)
=== RUN   TestSetUserType_Roundtrip
--- PASS: TestSetUserType_Roundtrip (0.00s)
=== RUN   TestGetUserPermissions_Found
--- PASS: TestGetUserPermissions_Found (0.00s)
=== RUN   TestGetUserPermissions_Missing
--- PASS: TestGetUserPermissions_Missing (0.00s)
=== RUN   TestGetUserPermissions_WrongType
--- PASS: TestGetUserPermissions_WrongType (0.00s)
=== RUN   TestSetUserPermissions_Roundtrip
--- PASS: TestSetUserPermissions_Roundtrip (0.00s)
=== RUN   TestValidateUserType
--- PASS: TestValidateUserType (0.00s)
=== RUN   TestValidatePermission
--- PASS: TestValidatePermission (0.00s)
PASS
ok  	pentagi/pkg/graph	4.026s

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

  • My code follows the project's coding standards
  • I have added/updated necessary documentation
  • I have added tests to cover my changes
  • All new and existing tests pass
  • I have run go fmt and go vet (for Go code)

Security

  • I have considered security implications
  • Changes maintain or improve the security model
  • Sensitive information has been properly handled

Compatibility

  • Changes are backward compatible
  • Breaking changes are clearly marked and documented
  • Dependencies are properly updated

Documentation

  • Documentation is clear and complete
  • Comments are added for non-obvious code
  • API changes are documented

Additional Notes

validatePermissionWithFlowID is intentionally excluded: it requires a database.Querier interface, which would need either a large mock or integration test infrastructure outside the scope of this narrow PR.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/vxcontrol/pentagi/pull/213 **Author:** [@mason5052](https://github.com/mason5052) **Created:** 3/17/2026 **Status:** ✅ Merged **Merged:** 3/20/2026 **Merged by:** [@asdek](https://github.com/asdek) **Base:** `feature/next_release` ← **Head:** `test/graph-context-coverage` --- ### 📝 Commits (1) - [`b130cd0`](https://github.com/vxcontrol/pentagi/commit/b130cd0a55c38193ee56b6b9c22b23145fd0ce46) test: add graph context helper coverage ### 📊 Changes **1 file changed** (+200 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `backend/pkg/graph/context_test.go` (+200 -0) </details> ### 📄 Description ### Description of the Change #### Problem `backend/pkg/graph/context.go` provides key context helper functions used throughout the graph layer (user ID, user type, permissions) but had no unit test coverage. #### Solution Add `context_test.go` with 20 focused unit tests covering all testable functions in the package. Closes N/A ### Type of Change - [x] 🧪 Test update ### Areas Affected - [x] Core Services (Frontend UI/Backend API) ### Testing and Verification #### Test Configuration ```yaml os: linux go: 1.24.1 ``` #### Test Steps 1. `go test ./pkg/graph/... -count=1` 2. `go test ./pkg/graph/... -count=1 -shuffle=on` 3. `go vet ./pkg/graph/...` #### Test Results ``` === RUN TestGetUserID_Found --- PASS: TestGetUserID_Found (0.00s) === RUN TestGetUserID_Missing --- PASS: TestGetUserID_Missing (0.00s) === RUN TestGetUserID_WrongType --- PASS: TestGetUserID_WrongType (0.00s) === RUN TestSetUserID_Roundtrip --- PASS: TestSetUserID_Roundtrip (0.00s) === RUN TestGetUserType_Found --- PASS: TestGetUserType_Found (0.00s) === RUN TestGetUserType_Missing --- PASS: TestGetUserType_Missing (0.00s) === RUN TestGetUserType_WrongType --- PASS: TestGetUserType_WrongType (0.00s) === RUN TestSetUserType_Roundtrip --- PASS: TestSetUserType_Roundtrip (0.00s) === RUN TestGetUserPermissions_Found --- PASS: TestGetUserPermissions_Found (0.00s) === RUN TestGetUserPermissions_Missing --- PASS: TestGetUserPermissions_Missing (0.00s) === RUN TestGetUserPermissions_WrongType --- PASS: TestGetUserPermissions_WrongType (0.00s) === RUN TestSetUserPermissions_Roundtrip --- PASS: TestSetUserPermissions_Roundtrip (0.00s) === RUN TestValidateUserType --- PASS: TestValidateUserType (0.00s) === RUN TestValidatePermission --- PASS: TestValidatePermission (0.00s) PASS ok pentagi/pkg/graph 4.026s ``` ### 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 - [x] My code follows the project's coding standards - [x] I have added/updated necessary documentation - [x] I have added tests to cover my changes - [x] All new and existing tests pass - [x] I have run `go fmt` and `go vet` (for Go code) #### Security - [x] I have considered security implications - [x] Changes maintain or improve the security model - [x] Sensitive information has been properly handled #### Compatibility - [x] Changes are backward compatible - [x] Breaking changes are clearly marked and documented - [x] Dependencies are properly updated #### Documentation - [x] Documentation is clear and complete - [x] Comments are added for non-obvious code - [x] API changes are documented ### Additional Notes `validatePermissionWithFlowID` is intentionally excluded: it requires a `database.Querier` interface, which would need either a large mock or integration test infrastructure outside the scope of this narrow PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-06-06 22:09:50 -04:00
yindo closed this issue 2026-06-06 22:09:50 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vxcontrol/pentagi#239