Skip to content

Commit 7d827c4

Browse files
Update Tests
1 parent 07dcf56 commit 7d827c4

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

tests/git-auto-commit.bats

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -690,8 +690,7 @@ cat_github_output() {
690690
assert_line -e "commit_hash=[0-9a-f]{40}$"
691691
}
692692

693-
@test "it creates new local branch and pushes branch to remote even if the remote branch already exists" {
694-
693+
@test "It creates new local branch and pushes branch to remote even if the remote branch already exists" {
695694
# Create `existing-remote-branch` on remote with changes the local repository does not yet have
696695
cd $FAKE_TEMP_LOCAL_REPOSITORY
697696
git checkout -b "existing-remote-branch"
@@ -708,7 +707,6 @@ cat_github_output() {
708707
cd $FAKE_LOCAL_REPOSITORY
709708

710709
INPUT_BRANCH="existing-remote-branch"
711-
INPUT_CREATE_BRANCH=true
712710

713711
run git branch
714712
refute_line --partial "existing-remote-branch"
@@ -736,13 +734,14 @@ cat_github_output() {
736734
assert_line "::debug::Push commit to remote branch existing-remote-branch"
737735

738736
run git branch
739-
assert_line --partial "existing-remote-branch"
737+
assert_line --partial ${FAKE_DEFAULT_BRANCH}
738+
refute_line --partial "existing-remote-branch"
740739

741740
run git branch -r
742741
assert_line --partial "origin/existing-remote-branch"
743742

744743
# Assert that branch "existing-remote-branch" was updated on remote
745-
current_sha="$(git rev-parse --verify --short existing-remote-branch)"
744+
current_sha="$(git rev-parse --verify --short ${FAKE_DEFAULT_BRANCH})"
746745
remote_sha="$(git rev-parse --verify --short origin/existing-remote-branch)"
747746

748747
assert_equal $current_sha $remote_sha
@@ -752,7 +751,7 @@ cat_github_output() {
752751
assert_line -e "commit_hash=[0-9a-f]{40}$"
753752
}
754753

755-
@test "script fails if new local branch is checked out and push fails as remote has newer commits than local" {
754+
@test "It fails if local branch is behind remote and when remote has newer commits" {
756755
# Create `existing-remote-branch` on remote with changes the local repository does not yet have
757756
cd $FAKE_TEMP_LOCAL_REPOSITORY
758757
git checkout -b "existing-remote-branch"
@@ -769,7 +768,6 @@ cat_github_output() {
769768
cd $FAKE_LOCAL_REPOSITORY
770769

771770
INPUT_BRANCH="existing-remote-branch"
772-
INPUT_CREATE_BRANCH=true
773771

774772
run git branch
775773
refute_line --partial "existing-remote-branch"
@@ -784,17 +782,18 @@ cat_github_output() {
784782

785783
assert_failure
786784

787-
assert_line "hint: Updates were rejected because the tip of your current branch is behind"
785+
assert_line "hint: Updates were rejected because a pushed branch tip is behind its remote"
788786

789787
# Assert that branch exists locally and on remote
790788
run git branch
791-
assert_line --partial "existing-remote-branch"
789+
assert_line --partial ${FAKE_DEFAULT_BRANCH}
790+
refute_line --partial "existing-remote-branch"
792791

793792
run git branch -r
794793
assert_line --partial "origin/existing-remote-branch"
795794

796795
# Assert that branch "existing-remote-branch" was not updated on remote
797-
current_sha="$(git rev-parse --verify --short existing-remote-branch)"
796+
current_sha="$(git rev-parse --verify --short ${FAKE_DEFAULT_BRANCH})"
798797
remote_sha="$(git rev-parse --verify --short origin/existing-remote-branch)"
799798

800799
refute [assert_equal $current_sha $remote_sha]

0 commit comments

Comments
 (0)