[Repo Assist] test(guards): add unit tests for issue_integrity and pr_integrity#8291
Merged
lpcox merged 1 commit intoJun 29, 2026
Conversation
Add 17 direct unit tests for the issue_integrity and pr_integrity functions in guards/github-guard/rust-guard/src/labels/helpers.rs, covering the T-GP-004 through T-GP-007 compliance scenarios that previously had no direct test coverage. Tests for issue_integrity (9 tests): - Blocked author returns blocked_integrity (T-GP-007 anchor) - Public repo / no author data gets none floor - Public repo NONE association gets reader floor - Public repo OWNER association gets writer floor - Private repo gets writer floor - Refusal label caps integrity to none (T-GP-004) - Approval label promotes reader to writer - Refusal label overrides approval label (T-GP-005) - Blocked user with refusal label returns blocked, not none (T-GP-007) Tests for pr_integrity (8 tests): - Blocked author returns blocked_integrity (T-GP-007 anchor) - Public direct PR gets writer floor - Public forked PR gets reader floor - Private repo gets writer floor - Merged PR gets merged floor (rank 4) - Refusal label caps PR integrity to none (T-GP-004) - Refusal label overrides approval label (T-GP-005) - Blocked user with refusal label returns blocked, not none (T-GP-007) The backend call_backend is stubbed to return -1 in tests, so enrichment paths gracefully fall back to baseline integrity without any external calls. Test run: all 556 Rust tests pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR strengthens the Rust GitHub guard’s integrity-labeling logic by adding direct unit coverage for the core issue_integrity and pr_integrity helpers in guards/github-guard/rust-guard/src/labels/helpers.rs, ensuring key precedence and floor rules are validated in isolation.
Changes:
- Add 9 unit tests covering
issue_integritybaseline floors, label precedence (approval vs refusal), and blocked-user priority. - Add 8 unit tests covering
pr_integrityfloors (forked/direct/private), merged promotion, refusal/approval precedence, and blocked-user priority. - Align new tests with the existing
commit_integritytest style (usingintegrity_rank(...)and explicitblocked_integrity(...)comparisons).
Show a summary per file
| File | Description |
|---|---|
| guards/github-guard/rust-guard/src/labels/helpers.rs | Adds focused unit tests for issue_integrity and pr_integrity covering floors, precedence, and blocked-user behavior. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Low
This was referenced Jun 29, 2026
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.
Summary
Adds 17 direct unit tests for the
issue_integrityandpr_integrityfunctions inguards/github-guard/rust-guard/src/labels/helpers.rs.These two core functions had zero direct unit tests despite being the primary implementation of T-GP-004 through T-GP-007 compliance scenarios (refusal-label demotion, approval/refusal override precedence, blocked-user priority).
Root Cause / Gap
The functions existed and were exercised indirectly via higher-level
labels::testsintegration tests, but no unit tests directly validated the function signatures, floor assignment rules, or compliance rule precedence in isolation.Tests Added
issue_integrity(9 tests)test_issue_integrity_blocked_author_returns_blockedblocked_integritytest_issue_integrity_public_repo_no_author_gets_none_floortest_issue_integrity_public_repo_none_association_gets_reader_floorauthor_association="NONE", public → rank 2 (reader)test_issue_integrity_public_repo_owner_association_gets_writer_floorauthor_association="OWNER"→ rank 3 (writer)test_issue_integrity_private_repo_gets_writer_floortest_issue_integrity_refusal_label_caps_to_nonetest_issue_integrity_approval_label_promotes_to_writertest_issue_integrity_refusal_label_overrides_approval_labeltest_issue_integrity_blocked_user_with_refusal_label_returns_blockedblocked_integrity(not just none) when blocked user has refusal labelpr_integrity(8 tests)test_pr_integrity_blocked_author_returns_blockedblocked_integritytest_pr_integrity_public_repo_direct_pr_gets_writer_floortest_pr_integrity_public_repo_forked_pr_gets_reader_floortest_pr_integrity_private_repo_gets_writer_floortest_pr_integrity_merged_pr_gets_merged_floormerged_atpresent → rank 4 (merged)test_pr_integrity_refusal_label_caps_to_nonetest_pr_integrity_refusal_label_overrides_approval_labeltest_pr_integrity_blocked_user_with_refusal_label_returns_blockedblocked_integrity(not just none) when blocked user has refusal labelImplementation Notes
call_backend) are stubbed to return-1in test mode via the existing#[cfg(test)]stub inlib.rs. All enrichment paths gracefully fall back to baseline integrity without external calls.commit_integritytests in the same file.blocked_integrity(a special label outsideINTEGRITY_LEVELS) is returned rather than just demoting tonone, ensuring blocked users are fully denied regardless of any label configuration.Test Status
Rust guard: All 556 tests pass (
cargo testinguards/github-guard/rust-guard/).Go unit tests: Failed to run due to
proxy.golang.orgnetwork access being blocked in this sandbox environment (infrastructure limitation unrelated to this change). Go tests pass in CI onmain.🤖 This pull request was created by Repo Assist, an automated AI assistant.
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
proxy.golang.orgSee Network Configuration for more information.
Add this agentic workflows to your repo
To install this agentic workflow, run