Skip to content

[Repo Assist] test(guards): add unit tests for issue_integrity and pr_integrity#8291

Merged
lpcox merged 1 commit into
mainfrom
repo-assist/test-issue-pr-integrity-compliance-91f49411fe14c6e6
Jun 29, 2026
Merged

[Repo Assist] test(guards): add unit tests for issue_integrity and pr_integrity#8291
lpcox merged 1 commit into
mainfrom
repo-assist/test-issue-pr-integrity-compliance-91f49411fe14c6e6

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Summary

Adds 17 direct unit tests for the issue_integrity and pr_integrity functions in guards/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::tests integration 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 Scenario
test_issue_integrity_blocked_author_returns_blocked Blocked user → blocked_integrity
test_issue_integrity_public_repo_no_author_gets_none_floor No author data, public repo → rank 1 (none)
test_issue_integrity_public_repo_none_association_gets_reader_floor author_association="NONE", public → rank 2 (reader)
test_issue_integrity_public_repo_owner_association_gets_writer_floor author_association="OWNER" → rank 3 (writer)
test_issue_integrity_private_repo_gets_writer_floor Private repo → rank 3 (writer floor)
test_issue_integrity_refusal_label_caps_to_none T-GP-004: refusal label → rank 1 (none), overrides OWNER association
test_issue_integrity_approval_label_promotes_to_writer Approval label raises reader floor → rank 3
test_issue_integrity_refusal_label_overrides_approval_label T-GP-005: refusal label wins over approval label
test_issue_integrity_blocked_user_with_refusal_label_returns_blocked T-GP-007: blocked_integrity (not just none) when blocked user has refusal label

pr_integrity (8 tests)

Test Scenario
test_pr_integrity_blocked_author_returns_blocked Blocked user → blocked_integrity
test_pr_integrity_public_repo_direct_pr_gets_writer_floor Direct (non-forked) PR → rank 3 (writer)
test_pr_integrity_public_repo_forked_pr_gets_reader_floor Forked PR → rank 2 (reader)
test_pr_integrity_private_repo_gets_writer_floor Private repo → rank 3 (writer floor)
test_pr_integrity_merged_pr_gets_merged_floor merged_at present → rank 4 (merged)
test_pr_integrity_refusal_label_caps_to_none T-GP-004: refusal label → rank 1 (none), overrides OWNER association
test_pr_integrity_refusal_label_overrides_approval_label T-GP-005: refusal label wins over approval label
test_pr_integrity_blocked_user_with_refusal_label_returns_blocked T-GP-007: blocked_integrity (not just none) when blocked user has refusal label

Implementation Notes

  • Backend calls (call_backend) are stubbed to return -1 in test mode via the existing #[cfg(test)] stub in lib.rs. All enrichment paths gracefully fall back to baseline integrity without external calls.
  • Tests follow the same pattern as the existing commit_integrity tests in the same file.
  • The T-GP-007 tests are particularly important: they verify that blocked_integrity (a special label outside INTEGRITY_LEVELS) is returned rather than just demoting to none, ensuring blocked users are fully denied regardless of any label configuration.

Test Status

Rust guard: All 556 tests pass (cargo test in guards/github-guard/rust-guard/).

Go unit tests: Failed to run due to proxy.golang.org network access being blocked in this sandbox environment (infrastructure limitation unrelated to this change). Go tests pass in CI on main.


🤖 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.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "proxy.golang.org"

See Network Configuration for more information.

Generated by Repo Assist · 613 AIC · ⊞ 12.2K ·
Comment /repo-assist to run again

Add this agentic workflows to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@851905c06e905bf362a9f6cc54f912e3df747d55

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>
@lpcox lpcox marked this pull request as ready for review June 29, 2026 14:33
Copilot AI review requested due to automatic review settings June 29, 2026 14:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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_integrity baseline floors, label precedence (approval vs refusal), and blocked-user priority.
  • Add 8 unit tests covering pr_integrity floors (forked/direct/private), merged promotion, refusal/approval precedence, and blocked-user priority.
  • Align new tests with the existing commit_integrity test style (using integrity_rank(...) and explicit blocked_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

@lpcox lpcox merged commit 566cd32 into main Jun 29, 2026
24 checks passed
@lpcox lpcox deleted the repo-assist/test-issue-pr-integrity-compliance-91f49411fe14c6e6 branch June 29, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants