From cd7c7f1a8ae6b99aa04d014d3280455924362e8a Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Sun, 11 Oct 2020 11:20:51 +0200 Subject: [PATCH] Add git-push-options-are-applied test --- tests/commit.bats | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/commit.bats b/tests/commit.bats index dbc06b1..646138c 100644 --- a/tests/commit.bats +++ b/tests/commit.bats @@ -273,3 +273,38 @@ main() { } +@test "git-push-options-are-applied" { + + INPUT_PUSH_OPTIONS="--force" + + touch "${test_repository}"/new-file-{1,2,3}.txt + + shellmock_expect git --type partial --output " M new-file-1.txt M new-file-2.txt M new-file-3.txt" --match "status" + shellmock_expect git --type exact --match "fetch" + shellmock_expect git --type exact --match "checkout master" + shellmock_expect git --type partial --match "add ." + shellmock_expect git --type partial --match '-c' + shellmock_expect git --type partial --match 'push --set-upstream origin' + + run main + + echo "$output" + + # Success Exit Code + [ "$status" = 0 ] + + [ "${lines[8]}" = "INPUT_PUSH_OPTIONS: --force" ] + [ "${lines[9]}" = "::debug::Apply push options --force" ] + [ "${lines[10]}" = "::debug::Push commit to remote branch master" ] + + + shellmock_verify + [ "${capture[0]}" = "git-stub status -s -- ." ] + [ "${capture[1]}" = "git-stub fetch" ] + [ "${capture[2]}" = "git-stub checkout master" ] + [ "${capture[3]}" = "git-stub add ." ] + [ "${capture[4]}" = "git-stub -c user.name=Test Suite -c user.email=test@github.com commit -m Commit Message --author=Test Suite " ] + [ "${capture[5]}" = "git-stub push --set-upstream origin HEAD:master --tags --force" ] + +} +