From e83c9825ac91b0eed4afd0df6cff7f2e9cdd1273 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?AJ=20C=C3=B4t=C3=A9?= <57828010+anderewrey@users.noreply.github.com> Date: Mon, 6 Jul 2026 14:53:06 -0400 Subject: [PATCH] test(scp): add coverage for -n/--dry-run and -i/--interactive abort git-scp had no test coverage at all. Cover the two paths that need no real remote destination: dry-run must preview without touching the index, working tree, or remote path, and declining the interactive confirmation must abort before anything syncs. --- tests/git-scp.bats | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 tests/git-scp.bats diff --git a/tests/git-scp.bats b/tests/git-scp.bats new file mode 100644 index 0000000..23930a0 --- /dev/null +++ b/tests/git-scp.bats @@ -0,0 +1,46 @@ +# shellcheck shell=bash + +source "$BATS_TEST_DIRNAME/test_util.sh" + +setup_file() { + test_util.setup_file +} + +setup() { + test_util.cd_test + + test_util.git_init + printf '%s\n' 'hello' > tracked.txt + git add tracked.txt + git commit -m 'Initial commit' + + # never created: neither test below should ever touch it + git remote add fake "$BATS_TEST_TMPDIR/never-created" + + printf '%s\n' 'world' >> tracked.txt +} + +@test "dry-run previews the sync without changing anything" { + run git scp -n fake + assert_success + assert_line -p 'tracked.txt' + assert_line -p 'DRY RUN' + + run git status --short + assert_line -p 'M tracked.txt' + + run test -e "$BATS_TEST_TMPDIR/never-created" + assert_failure +} + +@test "interactive mode aborts without syncing when declined" { + run bash -c 'echo n | git scp -i fake' + assert_success + assert_line -p 'Aborted, nothing synced.' + + run git status --short + assert_line -p 'M tracked.txt' + + run test -e "$BATS_TEST_TMPDIR/never-created" + assert_failure +}