Improve Assertions

This commit is contained in:
--global 2020-11-25 21:04:32 +01:00
parent fae0e424e9
commit b8b8026fe4

View File

@ -207,6 +207,14 @@ git_auto_commit() {
} }
@test "It applies INPUT_PUSH_OPTIONS when pushing commit to remote" { @test "It applies INPUT_PUSH_OPTIONS when pushing commit to remote" {
touch "${FAKE_TEMP_LOCAL_REPOSITORY}"/newer-remote-files{1,2,3}.txt
cd "${FAKE_TEMP_LOCAL_REPOSITORY}";
git add .;
git commit --quiet -m "Add more remote files";
git push origin master;
INPUT_PUSH_OPTIONS="--force" INPUT_PUSH_OPTIONS="--force"
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{1,2,3}.txt touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{1,2,3}.txt
@ -219,8 +227,12 @@ git_auto_commit() {
assert_line "::debug::Apply push options --force" assert_line "::debug::Apply push options --force"
assert_line "::debug::Push commit to remote branch master" assert_line "::debug::Push commit to remote branch master"
# TODO: Assert that on last push --force was used # Assert that the commit has been pushed with --force and
# Assert that ref-log on local and remote are the same # sha values are equal on local and remote
current_sha="$(git rev-parse --verify --short master)"
remote_sha="$(git rev-parse --verify --short origin/master)"
assert_equal $current_sha $remote_sha
} }
@test "It can checkout a different branch" { @test "It can checkout a different branch" {
@ -239,7 +251,9 @@ git_auto_commit() {
assert_line "INPUT_BRANCH value: foo" assert_line "INPUT_BRANCH value: foo"
assert_line "::debug::Push commit to remote branch foo" assert_line "::debug::Push commit to remote branch foo"
# TODO: Assert a new branch "foo" exists on remote # Assert a new branch "foo" exists on remote
run git ls-remote --heads
assert_output --partial refs/heads/foo
} }
@test "It uses existing branch name when pushing when INPUT_BRANCH is empty" { @test "It uses existing branch name when pushing when INPUT_BRANCH is empty" {
@ -254,7 +268,11 @@ git_auto_commit() {
assert_line "INPUT_BRANCH value: " assert_line "INPUT_BRANCH value: "
assert_line --partial "::debug::git push origin" assert_line --partial "::debug::git push origin"
# TODO: Assert that branch "master" was updated on remote # Assert that branch "master" was updated on remote
current_sha="$(git rev-parse --verify --short master)"
remote_sha="$(git rev-parse --verify --short origin/master)"
assert_equal $current_sha $remote_sha
} }
@test "It uses existing branch when INPUT_BRANCH is empty and INPUT_TAGGING_MESSAGE is set" { @test "It uses existing branch when INPUT_BRANCH is empty and INPUT_TAGGING_MESSAGE is set" {