Files
Coredesktop-Dev/tests/deployed.bats
T
2026-11-04 09:43:05 -07:00

57 lines
1.6 KiB
Bash

#!/usr/bin/env bats
load test_helper
@test "deployed status shows the commit, how far behind, and local changes" {
make_working_copy
git -C "$WC" commit -q --allow-empty -m "new"
git -C "$WC" push -q origin main
echo "# edited" >> "$DEPLOYED/update"
run cdd deployed
[ "$status" -eq 0 ]
[[ "$output" == *"Branch: main"* ]]
[[ "$output" == *"CoreDesktop"* ]]
[[ "$output" == *"Behind: 1 commits"* ]]
[[ "$output" == *"M update"* ]]
}
@test "deployed restore asks first, and changes nothing on no" {
echo "# edited" >> "$DEPLOYED/update"
run cdd deployed restore <<< n
[ "$status" -eq 1 ]
[[ "$output" == *"Nothing changed."* ]]
grep -q "# edited" "$DEPLOYED/update"
}
@test "deployed restore puts back tracked files and leaves untracked ones" {
echo "# edited" >> "$DEPLOYED/update"
rm "$DEPLOYED/utils.sh"
echo "mine" > "$DEPLOYED/untracked-file"
run cdd deployed restore <<< y
[ "$status" -eq 0 ]
[[ "$output" == *"untracked-file"* ]]
[ -f "$DEPLOYED/utils.sh" ]
[ "$(cat "$DEPLOYED/untracked-file")" = mine ]
[ -z "$(git -C "$DEPLOYED" status --porcelain --untracked-files=no)" ]
run grep -q "# edited" "$DEPLOYED/update"
[ "$status" -eq 1 ]
}
@test "deployed restore puts back staged changes too" {
echo "# edited" >> "$DEPLOYED/update"
git -C "$DEPLOYED" add update
run cdd deployed restore <<< y
[ "$status" -eq 0 ]
[ -z "$(git -C "$DEPLOYED" status --porcelain --untracked-files=no)" ]
}
@test "deployed restore with nothing to restore doesn't ask" {
run cdd deployed restore < /dev/null
[ "$status" -eq 0 ]
[[ "$output" == *"no local changes"* ]]
}