From b330e62469e7873078ef301272caaf448890fcb4 Mon Sep 17 00:00:00 2001 From: joe miller Date: Mon, 5 Aug 2024 15:41:33 +0000 Subject: [PATCH] fix tests recent changes modified the stdout from the entrypoint.sh script. update the tests to reflect this --- tests/entrypoint.bats | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/entrypoint.bats b/tests/entrypoint.bats index 9bfe41f..1ab1da1 100644 --- a/tests/entrypoint.bats +++ b/tests/entrypoint.bats @@ -8,6 +8,7 @@ load "${BATS_PLUGIN_PATH}/load.bash" setup() { export GITHUB_WORKSPACE=/tmp + #export DEBUG=1 } @test "parses git status output and generates correct flags for ghcommit" { @@ -17,6 +18,8 @@ setup() { local empty='false' local file_pattern='.' + export GITHUB_OUTPUT="$BATS_TEST_TMPDIR/github-output" + # NOTE: we are passing our hand-crafted fixture through `tr` to convert newlines to nulls since # we run `git status -z` which uses null terminators. The newlines are meant to make the file easier # to modify and prevent cat from removing the leading space on lines/entries since that is a part @@ -26,11 +29,13 @@ setup() { "status -s --porcelain=v1 -z -- . : cat ./tests/fixtures/git-status.out-1 | tr '\n' '\0'" stub ghcommit \ - '-b main -r org/repo -m msg --add=README.md --add=foo.txt --add=new.file --delete=old.file --delete=\""a path with spaces oh joy/file.txt\"" : echo Success' + '-b main -r org/repo -m msg --add=README.md --add=foo.txt --add=new.file --delete=old.file --delete=\""a path with spaces oh joy/file.txt\"" : echo Success. New commit: https://localhost/foo' run ./entrypoint.sh "$commit_message" "$repo" "$branch" "$empty" "$file_pattern" assert_success assert_output --partial "Success" + assert_file_exist "$GITHUB_OUTPUT" + assert_file_contains "$GITHUB_OUTPUT" "commit-url=https://localhost/foo" } @test "no changes" { @@ -56,14 +61,18 @@ setup() { local empty='true' local file_pattern='.' + export GITHUB_OUTPUT="$BATS_TEST_TMPDIR/github-output" + stub git \ "config --global --add safe.directory $GITHUB_WORKSPACE : echo stubbed" \ "status -s --porcelain=v1 -z -- . : echo" stub ghcommit \ - '-b main -r org/repo -m msg --empty : echo Success' + '-b main -r org/repo -m msg --empty : echo Success. New commit: https://localhost/foo' run ./entrypoint.sh "$commit_message" "$repo" "$branch" "$empty" "$file_pattern" assert_success assert_output --partial "Success" + assert_file_exist "$GITHUB_OUTPUT" + assert_file_contains "$GITHUB_OUTPUT" "commit-url=https://localhost/foo" }