Test presence: add bats coverage for add-submodules, sync_repo_master, Weblate POST.#44
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughAdds Bats coverage for sync_repo_master, translations submodule management, and trigger_weblate, plus shared test helpers for a mock Weblate endpoint and curl timeout stubbing. Updates the lint workflow to install jq and curl, and extends one existing submodule assertion. ChangesTest infrastructure and coverage
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
tests/test_sync_repo_master.bats (1)
34-37: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winPrefer bats' built-in
runhelper over manualset +e/set -e.The repeated
set +e; cmd; status=$?; set -epattern across all three tests can be replaced with bats'runhelper, which captures$status/$outputwithout disablingerrexitand is the idiomatic bats pattern.♻️ Proposed refactor (example for first test)
- set +e - sync_repo_master "$dest_repo" "$sub_clone" "$libs_ref" - status=$? - set -e - - [ "$status" -eq 0 ] + run sync_repo_master "$dest_repo" "$sub_clone" "$libs_ref" + [ "$status" -eq 0 ]Apply the same simplification to the other two
@testblocks.Bats includes a run helper that invokes its arguments as a command, saves the exit status and output into special global variables, and then returns with a 0 status code so you can continue to make assertions in your test case.
Also applies to: 56-59, 74-77
🤖 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 `@tests/test_sync_repo_master.bats` around lines 34 - 37, The three `@test` blocks in tests/test_sync_repo_master.bats are using manual set +e / set -e to capture exit status; replace that pattern with bats’ built-in run helper so the command output and exit code are captured idiomatically without toggling errexit. Update the sync_repo_master call in each test to use run, then assert against the special bats variables ($status and any relevant output) in the existing test flow, keeping the same behavior across all three blocks.
🤖 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.
Inline comments:
In `@tests/helpers/http_mock.bash`:
- Around line 25-30: The mock server startup in http_mock.bash has a
port-selection race because the ephemeral port is chosen before HTTPServer binds
it. Update the server process entrypoint and readiness flow so HTTPServer binds
to port 0 itself, then communicate the assigned port back to Bash and use that
value for polling/connect logic. Keep the fix centered around the mock server
startup and readiness loop symbols that manage port selection and server
creation.
In `@tests/test_trigger_weblate.bats`:
- Around line 38-41: The JSON checks in the trigger Weblate test are too loose
and do not verify the payload shape. Tighten the assertions in the test that
uses body_json and jq so `add_or_update.en` is validated as an array containing
the expected entries, and `extensions` is validated as the expected JSON array
structure rather than just existing. Use the existing test block in
tests/test_trigger_weblate.bats to make the contract explicit and catch shape
regressions earlier.
---
Nitpick comments:
In `@tests/test_sync_repo_master.bats`:
- Around line 34-37: The three `@test` blocks in tests/test_sync_repo_master.bats
are using manual set +e / set -e to capture exit status; replace that pattern
with bats’ built-in run helper so the command output and exit code are captured
idiomatically without toggling errexit. Update the sync_repo_master call in each
test to use run, then assert against the special bats variables ($status and any
relevant output) in the existing test flow, keeping the same behavior across all
three blocks.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 4af683a3-7c10-40f6-8ee4-649c7d27f68b
📒 Files selected for processing (7)
.github/workflows/lint.ymltests/helpers/http_mock.bashtests/helpers/test_helper.bashtests/test_add_one_submodule.batstests/test_sync_repo_master.batstests/test_translations_submodule.batstests/test_trigger_weblate.bats
Close #37.
Summary by CodeRabbit
sync_repo_master,translationssubmodule updates, andtrigger_weblate.