Skip to content

test: add internal server coverage#3034

Merged
omer-topal merged 1 commit into
masterfrom
test/internal-servers-coverage
Jul 8, 2026
Merged

test: add internal server coverage#3034
omer-topal merged 1 commit into
masterfrom
test/internal-servers-coverage

Conversation

@omer-topal

@omer-topal omer-topal commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Tests
    • Added comprehensive server behavior tests covering health checks, request handling, logging, permissions, tenancy, and bundle operations.
    • Verified expected responses for valid and invalid requests, including error handling and status mapping.
    • Added coverage for helper behavior such as route formatting and dependency wiring.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

πŸ“ Walkthrough

Walkthrough

Adds a new test file for the internal/servers package, introducing fake tenant/bundle storage and permission invoker implementations plus request builders, and unit tests covering health checks, container wiring, HTTP naming, logging, and permission/tenancy/bundle server behaviors.

Changes

Server behavior tests

Layer / File(s) Summary
Test fakes and request builders
internal/servers/server_behavior_test.go
Adds in-memory fake tenant storage, bundle storage, permission invoker, and helper functions building valid protobuf permission requests.
Health, container, HTTP naming, and logging tests
internal/servers/server_behavior_test.go
Tests health server Check/Watch/AuthFuncOverride, container dependency wiring, HTTP name formatter fallback/gateway naming, and interceptor logger field output.
Permission server pass-through and validation tests
internal/servers/server_behavior_test.go
Tests permission RPCs forward to the invoker and return its results, and that invalid requests are rejected while invoker errors map to gRPC status codes.
Tenancy server tests
internal/servers/server_behavior_test.go
Tests tenancy create/delete/list operations against the store and storage error mapping to NotFound.
Bundle server tests
internal/servers/server_behavior_test.go
Tests bundle write/read/delete operations, duplicate-operation validation failures, and storage error mapping to NotFound.

Estimated code review effort: 2 (Simple) | ~15 minutes

πŸš₯ Pre-merge checks | βœ… 5
βœ… Passed checks (5 passed)
Check name Status Explanation
Description Check βœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check βœ… Passed The title clearly matches the change: it adds test coverage for internal server behavior.
Docstring Coverage βœ… Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check βœ… Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check βœ… Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
πŸ“ Generate docstrings
  • Create stacked PR
  • Commit on current branch
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/internal-servers-coverage

Warning

Review ran into problems

πŸ”₯ Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
internal/servers/server_behavior_test.go (2)

499-501: πŸ“ Maintainability & Code Quality | πŸ”΅ Trivial | πŸ’€ Low value

Use reflect.DeepEqual instead of pointer comparison for bundle assertion.

read.GetBundle() != bundle relies on the fake store returning the exact same *v1.DataBundle pointer. This works today but is fragile β€” if the server or store ever clones the proto, the test fails for the wrong reason. The rest of the file already uses reflect.DeepEqual for value comparisons (lines 365, 374, 443, 485).

♻️ Suggested fix
-	if read.GetBundle() != bundle {
+	if !reflect.DeepEqual(read.GetBundle(), bundle) {
 		t.Fatalf("expected stored bundle, got %v", read.GetBundle())
πŸ€– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/servers/server_behavior_test.go` around lines 499 - 501, The bundle
assertion in the test should compare values instead of pointer identity, since
`read.GetBundle()` may return an equivalent but different `*v1.DataBundle`.
Update the assertion in the server behavior test to use `reflect.DeepEqual` for
the `bundle` check, matching the existing value-based comparisons already used
elsewhere in `server_behavior_test.go` and keeping the test tied to
`GetBundle()` contents rather than object identity.

148-151: πŸ“ Maintainability & Code Quality | πŸ”΅ Trivial | ⚑ Quick win

LookupEntityStream is implemented in the fake but never exercised by any test.

The fake implements LookupEntityStream (lines 148-151) to satisfy the Permission interface, but TestPermissionServerPassesThroughInvoker covers every other RPC (Check, Expand, LookupEntity, LookupSubject, SubjectPermission) except the streaming LookupEntityStream. Consider adding a test that verifies the server forwards the request to the invoker and streams the response.

Also applies to: 335-387

πŸ€– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/servers/server_behavior_test.go` around lines 148 - 151, Add test
coverage for the streaming Permission RPC by exercising
fakePermissionInvoker.LookupEntityStream from
TestPermissionServerPassesThroughInvoker or a new focused test. Verify
PermissionServer.LookupEntityStream forwards the request to the invoker, uses
the fake to capture the request, and streams the response back to the client,
similar to the existing coverage for Check, Expand, LookupEntity, LookupSubject,
and SubjectPermission.
πŸ€– Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@internal/servers/server_behavior_test.go`:
- Around line 499-501: The bundle assertion in the test should compare values
instead of pointer identity, since `read.GetBundle()` may return an equivalent
but different `*v1.DataBundle`. Update the assertion in the server behavior test
to use `reflect.DeepEqual` for the `bundle` check, matching the existing
value-based comparisons already used elsewhere in `server_behavior_test.go` and
keeping the test tied to `GetBundle()` contents rather than object identity.
- Around line 148-151: Add test coverage for the streaming Permission RPC by
exercising fakePermissionInvoker.LookupEntityStream from
TestPermissionServerPassesThroughInvoker or a new focused test. Verify
PermissionServer.LookupEntityStream forwards the request to the invoker, uses
the fake to capture the request, and streams the response back to the client,
similar to the existing coverage for Check, Expand, LookupEntity, LookupSubject,
and SubjectPermission.

ℹ️ Review info
βš™οΈ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 745f0ba1-f2bd-4ef4-8904-f756bbe1f984

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between e62cb3e and 0e4d58e.

πŸ“’ Files selected for processing (1)
  • internal/servers/server_behavior_test.go

@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

βœ… All modified and coverable lines are covered by tests.
βœ… Project coverage is 76.24%. Comparing base (e62cb3e) to head (0e4d58e).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3034      +/-   ##
==========================================
+ Coverage   74.67%   76.24%   +1.58%     
==========================================
  Files          83       83              
  Lines        9212     9212              
==========================================
+ Hits         6878     7023     +145     
+ Misses       1798     1638     -160     
- Partials      536      551      +15     

β˜” View full report in Codecov by Harness.
πŸ“’ Have feedback on the report? Share it here.

πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • πŸ“¦ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@omer-topal
omer-topal merged commit 6e901c8 into master Jul 8, 2026
14 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant