Repository navigation
feat: implement issue #320 — Compliance: check-suite-prefs-unreadable #327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
23bb8b0
feat: implement issue #320 — Compliance: check-suite-prefs-unreadable
donpetry-bot 7e539d8
chore: apply manual instructions [skip ci-relay]
donpetry-bot b4380c3
Merge branch 'main' into dev-lead/issue-320-20260619-1539
don-petry 765a7a1
Merge branch 'main' into dev-lead/issue-320-20260619-1539
don-petry 736d3bf
Merge branch 'main' into dev-lead/issue-320-20260619-1539
don-petry 95e4b29
Merge branch 'main' into dev-lead/issue-320-20260619-1539
don-petry 3ea2467
Merge branch 'main' into dev-lead/issue-320-20260619-1539
don-petry 55289de
Merge branch 'main' into dev-lead/issue-320-20260619-1539
don-petry 741c754
Merge branch 'main' into dev-lead/issue-320-20260619-1539
don-petry 7e4567e
Merge branch 'main' into dev-lead/issue-320-20260619-1539
don-petry File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| #!/usr/bin/env bats | ||
| # Integration tests for scripts/apply-repo-settings.sh | ||
| # | ||
| # These tests stub the `gh` and `jq` CLIs so the script can run without network | ||
| # access or real credentials, and assert that it targets the correct GitHub REST | ||
| # endpoint for check-suite preferences (`check-suites/preferences`, plural). | ||
|
|
||
| setup() { | ||
| REPO_ROOT="$(cd "$BATS_TEST_DIRNAME/../.." && pwd)" | ||
| SCRIPT="$REPO_ROOT/scripts/apply-repo-settings.sh" | ||
|
|
||
| BIN_DIR="$BATS_TEST_TMPDIR/bin" | ||
| mkdir -p "$BIN_DIR" | ||
| CALL_LOG="$BATS_TEST_TMPDIR/gh-calls.log" | ||
|
|
||
| # Mock `gh`: record every invocation, satisfy the repo-identity safety check, | ||
| # and succeed on the PATCH without making a network call. | ||
| cat > "$BIN_DIR/gh" <<MOCK | ||
| #!/usr/bin/env bash | ||
| printf '%s\n' "\$*" >> "$CALL_LOG" | ||
| if [ "\$1" = "repo" ] && [ "\$2" = "view" ]; then | ||
| echo "petry-projects/broodly" | ||
| exit 0 | ||
| fi | ||
| # Drain stdin for the PATCH --input - call so the pipe does not break. | ||
| if [ "\$1" = "api" ]; then | ||
| cat > /dev/null 2>&1 || true | ||
| exit 0 | ||
| fi | ||
| exit 0 | ||
| MOCK | ||
| chmod +x "$BIN_DIR/gh" | ||
|
|
||
|
don-petry marked this conversation as resolved.
Resolved
|
||
| # Mock `jq`: pass stdin through to stdout so dry-run output works without | ||
| # requiring jq to be installed on the host. | ||
| cat > "$BIN_DIR/jq" <<MOCK | ||
| #!/usr/bin/env bash | ||
| cat | ||
| MOCK | ||
| chmod +x "$BIN_DIR/jq" | ||
|
|
||
| export PATH="$BIN_DIR:$PATH" | ||
| export GH_TOKEN="test-token" | ||
| } | ||
|
|
||
| @test "applies check-suite preferences via the plural check-suites/preferences endpoint" { | ||
| run bash "$SCRIPT" broodly | ||
| [ "$status" -eq 0 ] | ||
| grep -q "api -X PATCH repos/petry-projects/broodly/check-suites/preferences" "$CALL_LOG" | ||
| } | ||
|
|
||
| @test "never targets the non-existent singular check-suite/preferences endpoint" { | ||
| run bash "$SCRIPT" broodly | ||
| [ "$status" -eq 0 ] | ||
| ! grep -qE "repos/petry-projects/broodly/check-suite/preferences" "$CALL_LOG" | ||
| } | ||
|
|
||
| @test "dry-run makes no PATCH call" { | ||
| run bash "$SCRIPT" broodly --dry-run | ||
| [ "$status" -eq 0 ] | ||
| ! grep -q "api -X PATCH" "$CALL_LOG" | ||
| } | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.