Problem
lib/bash/git/tests/lib_git.bats tests the happy path of git_update_repo but does not cover:
- Network timeout / remote unreachable —
git fetch hangs or fails; git_update_repo should return non-zero and not mutate the worktree.
- Non-fast-forward update — the remote has diverged (force-pushed or rebased);
--ff-only will fail. The test should verify the local branch is left unchanged.
- Dirty worktree —
basectl update explicitly checks for a clean worktree, but this is checked in update.sh before calling git_update_repo. There is no test that validates the integration between the clean-worktree guard and the git library.
- Missing remote — no
origin remote configured; git_update_repo should fail clearly.
These are precisely the scenarios that matter in real CI and offline development environments.
Proposed Tests
@test "git_update_repo fails clearly when remote is unreachable" {
# set remote to a non-existent URL
...
run ... git_update_repo "$repo" "" "$branch"
[ "$status" -ne 0 ]
[[ "$output" == *"fetch"* || "$status" -ne 0 ]]
# local branch should be unchanged
}
@test "git_update_repo fails on non-fast-forward and leaves branch unchanged" {
# set up diverged history with forced push simulation
...
}
Why This Matters
basectl update is a command users will run when something is already wrong (they need a bug fix). A failure in the update path — especially a silent one that partially mutates the repo — is the worst time for the tool to be unreliable.
Problem
lib/bash/git/tests/lib_git.batstests the happy path ofgit_update_repobut does not cover:git fetchhangs or fails;git_update_reposhould return non-zero and not mutate the worktree.--ff-onlywill fail. The test should verify the local branch is left unchanged.basectl updateexplicitly checks for a clean worktree, but this is checked inupdate.shbefore callinggit_update_repo. There is no test that validates the integration between the clean-worktree guard and the git library.originremote configured;git_update_reposhould fail clearly.These are precisely the scenarios that matter in real CI and offline development environments.
Proposed Tests
Why This Matters
basectl updateis a command users will run when something is already wrong (they need a bug fix). A failure in the update path — especially a silent one that partially mutates the repo — is the worst time for the tool to be unreliable.