Skip to content

Commit 5fe35a0

Browse files
committed
Restore Tests
1 parent 2da8d96 commit 5fe35a0

1 file changed

Lines changed: 35 additions & 6 deletions

File tree

tests/git-auto-commit.bats

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,11 @@ setup() {
3535
export INPUT_TAGGING_MESSAGE=""
3636
export INPUT_PUSH_OPTIONS=""
3737
export INPUT_SKIP_DIRTY_CHECK=false
38-
export INPUT_DISABLE_GLOBBING=false
39-
export INPUT_INTERNAL_GIT_BINARY=git
40-
41-
# Deprecated variables. Will be removed in future versions
42-
export INPUT_CREATE_BRANCH=false
4338
export INPUT_SKIP_FETCH=false
4439
export INPUT_SKIP_CHECKOUT=false
40+
export INPUT_DISABLE_GLOBBING=false
41+
export INPUT_CREATE_BRANCH=false
42+
export INPUT_INTERNAL_GIT_BINARY=git
4543

4644
# Set GitHub environment variables used by the GitHub Action
4745
temp_github_output_file=$(mktemp -t github_output_test.XXXXX)
@@ -411,6 +409,32 @@ cat_github_output() {
411409
assert_output --partial refs/tags/v2.0.0
412410
}
413411

412+
@test "If SKIP_FETCH is true git-fetch will not be called" {
413+
414+
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{1,2,3}.txt
415+
416+
INPUT_SKIP_FETCH=true
417+
418+
run git_auto_commit
419+
420+
assert_success
421+
422+
assert_line "::debug::git-fetch will not be executed."
423+
}
424+
425+
@test "If SKIP_CHECKOUT is true git-checkout will not be called" {
426+
427+
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{1,2,3}.txt
428+
429+
INPUT_SKIP_CHECKOUT=true
430+
431+
run git_auto_commit
432+
433+
assert_success
434+
435+
assert_line "::debug::git-checkout will not be executed."
436+
}
437+
414438
@test "It pushes generated commit and tag to remote and actually updates the commit shas" {
415439
INPUT_BRANCH=""
416440
INPUT_TAGGING_MESSAGE="v2.0.0"
@@ -441,6 +465,10 @@ cat_github_output() {
441465
}
442466

443467
@test "It pushes generated commit and tag to remote branch and updates commit sha" {
468+
# Create "a-new-branch"-branch and then immediately switch back to ${FAKE_DEFAULT_BRANCH}
469+
git checkout -b a-new-branch
470+
git checkout ${FAKE_DEFAULT_BRANCH}
471+
444472
INPUT_BRANCH="a-new-branch"
445473
INPUT_TAGGING_MESSAGE="v2.0.0"
446474

@@ -463,7 +491,7 @@ cat_github_output() {
463491
assert_output --partial refs/tags/v2.0.0
464492

465493
# Assert that branch "a-new-branch" was updated on remote
466-
current_sha="$(git rev-parse --verify --short ${FAKE_DEFAULT_BRANCH})"
494+
current_sha="$(git rev-parse --verify --short a-new-branch)"
467495
remote_sha="$(git rev-parse --verify --short origin/a-new-branch)"
468496

469497
assert_equal $current_sha $remote_sha
@@ -507,6 +535,7 @@ cat_github_output() {
507535
@test "it does not throw an error if not changes are detected and SKIP_DIRTY_CHECK is false" {
508536
INPUT_FILE_PATTERN="."
509537
INPUT_SKIP_DIRTY_CHECK=false
538+
INPUT_SKIP_FETCH=false
510539

511540
run git_auto_commit
512541

0 commit comments

Comments
 (0)