From e7c0a5aac29536d9cc44cf4f7a8b73b76e80a7eb Mon Sep 17 00:00:00 2001 From: Phil Jay Date: Wed, 19 Oct 2022 08:51:44 +1100 Subject: [PATCH] Update tests to _not_ expect `set-output` --- tests/test_version-increment.bats | 48 ++++++++++++++++++------------- tests/test_version-lookup.bats | 25 ++++++++++------ 2 files changed, 44 insertions(+), 29 deletions(-) diff --git a/tests/test_version-increment.bats b/tests/test_version-increment.bats index 457e815..4e15087 100644 --- a/tests/test_version-increment.bats +++ b/tests/test_version-increment.bats @@ -65,6 +65,13 @@ function init_repo { [[ "$output" = *"Value of 'increment' is not valid, choose from 'major', 'minor', or 'patch'"* ]] } +@test "no deprecated set-output calls made" { + run grep -q "::set-output" version-increment.sh + + print_run_info + [ "$status" -eq 1 ] +} + @test "increments the patch digit correctly (semver)" { init_repo @@ -75,10 +82,10 @@ function init_repo { print_run_info [ "$status" -eq 0 ] && - [[ "$output" = *"::set-output name=major-version::1"* ]] && - [[ "$output" = *"::set-output name=minor-version::2"* ]] && - [[ "$output" = *"::set-output name=patch-version::4"* ]] && - [[ "$output" = *"::set-output name=version::1.2.4"* ]] + [[ "$output" = *"MAJOR_VERSION=1"* ]] && + [[ "$output" = *"MINOR_VERSION=2"* ]] && + [[ "$output" = *"PATCH_VERSION=4"* ]] && + [[ "$output" = *"VERSION=1.2.4"* ]] } @test "increments the minor digit correctly (semver)" { @@ -91,10 +98,10 @@ function init_repo { print_run_info [ "$status" -eq 0 ] && - [[ "$output" = *"::set-output name=major-version::1"* ]] && - [[ "$output" = *"::set-output name=minor-version::3"* ]] && - [[ "$output" = *"::set-output name=patch-version::0"* ]] && - [[ "$output" = *"::set-output name=version::1.3.0"* ]] + [[ "$output" = *"MAJOR_VERSION=1"* ]] && + [[ "$output" = *"MINOR_VERSION=3"* ]] && + [[ "$output" = *"PATCH_VERSION=0"* ]] && + [[ "$output" = *"VERSION=1.3.0"* ]] } @test "increments the major digit correctly (semver)" { @@ -107,10 +114,10 @@ function init_repo { print_run_info [ "$status" -eq 0 ] && - [[ "$output" = *"::set-output name=major-version::2"* ]] && - [[ "$output" = *"::set-output name=minor-version::0"* ]] && - [[ "$output" = *"::set-output name=patch-version::0"* ]] && - [[ "$output" = *"::set-output name=version::2.0.0"* ]] + [[ "$output" = *"MAJOR_VERSION=2"* ]] && + [[ "$output" = *"MINOR_VERSION=0"* ]] && + [[ "$output" = *"PATCH_VERSION=0"* ]] && + [[ "$output" = *"VERSION=2.0.0"* ]] } @test "prefixes with v" { @@ -123,11 +130,11 @@ function init_repo { print_run_info [ "$status" -eq 0 ] && - [[ "$output" = *"::set-output name=version::2.0.0"* ]] && - [[ "$output" = *"::set-output name=major-v-version::v2"* ]] && - [[ "$output" = *"::set-output name=minor-v-version::v0"* ]] && - [[ "$output" = *"::set-output name=patch-v-version::v0"* ]] && - [[ "$output" = *"::set-output name=v-version::v2.0.0"* ]] + [[ "$output" = *"VERSION=2.0.0"* ]] && + [[ "$output" = *"MAJOR_V_VERSION=v2"* ]] && + [[ "$output" = *"MINOR_V_VERSION=v0"* ]] && + [[ "$output" = *"PATCH_V_VERSION=v0"* ]] && + [[ "$output" = *"V_VERSION=v2.0.0"* ]] } @test "increments to a new month (calver)" { @@ -140,7 +147,7 @@ function init_repo { print_run_info [ "$status" -eq 0 ] && - [[ "$output" = *"::set-output name=version::$(date +%Y.%-m.1)"* ]] + [[ "$output" = *"VERSION=$(date +%Y.%-m.1)"* ]] } @test "increments the patch digit within a month (calver)" { @@ -153,7 +160,7 @@ function init_repo { print_run_info [ "$status" -eq 0 ] && - [[ "$output" = *"::set-output name=version::$(date +%Y.%-m.124)"* ]] + [[ "$output" = *"VERSION=$(date +%Y.%-m.124)"* ]] } @test "appends prerelease information if on a branch" { @@ -167,5 +174,6 @@ function init_repo { print_run_info [ "$status" -eq 0 ] && - [[ "$output" = *"::set-output name=version::1.2.4-pre.${short_ref}"* ]] + [[ "$output" = *"PRE_RELEASE_LABEL=pre.${short_ref}"* ]] + [[ "$output" = *"VERSION=1.2.4-pre.${short_ref}"* ]] } diff --git a/tests/test_version-lookup.bats b/tests/test_version-lookup.bats index 1ea10d1..1287999 100644 --- a/tests/test_version-lookup.bats +++ b/tests/test_version-lookup.bats @@ -29,6 +29,13 @@ function init_repo { [[ "$output" = *"Value of 'scheme' is not valid"* ]] } +@test "no deprecated set-output calls made" { + run grep -q "::set-output" version-lookup.sh + + print_run_info + [ "$status" -eq 1 ] +} + @test "finds the current normal version" { init_repo @@ -40,7 +47,7 @@ function init_repo { print_run_info [ "$status" -eq 0 ] && - [[ "$output" = *"::set-output name=current-version::0.1.2"* ]] + [[ "$output" = *"CURRENT_VERSION=0.1.2"* ]] } @test "prefixes with a v" { @@ -52,8 +59,8 @@ function init_repo { print_run_info [ "$status" -eq 0 ] && - [[ "$output" = *"::set-output name=current-version::0.1.2"* ]] && - [[ "$output" = *"::set-output name=current-v-version::v0.1.2"* ]] + [[ "$output" = *"CURRENT_VERSION=0.1.2"* ]] && + [[ "$output" = *"CURRENT_V_VERSION=v0.1.2"* ]] } @test "finds the current normal version even if there's a newer pre-release version" { @@ -66,7 +73,7 @@ function init_repo { print_run_info [ "$status" -eq 0 ] && - [[ "$output" = *"::set-output name=current-version::1.2.300"* ]] + [[ "$output" = *"CURRENT_VERSION=1.2.300"* ]] } @test "returns 0.0.0 if no normal version detected" { @@ -76,7 +83,7 @@ function init_repo { print_run_info [ "$status" -eq 0 ] && - [[ "$output" = *"::set-output name=current-version::0.0.0"* ]] + [[ "$output" = *"CURRENT_VERSION=0.0.0"* ]] } @test "returns 0.0.0 if no normal version detected even if there's a pre-release version" { @@ -88,7 +95,7 @@ function init_repo { print_run_info [ "$status" -eq 0 ] && - [[ "$output" = *"::set-output name=current-version::0.0.0"* ]] + [[ "$output" = *"CURRENT_VERSION=0.0.0"* ]] } @test "returns a calver if no normal version detected and calver scheme specified" { @@ -100,7 +107,7 @@ function init_repo { print_run_info [ "$status" -eq 0 ] && - [[ "$output" = *"::set-output name=current-version::$(date '+%Y.%-m.0')"* ]] + [[ "$output" = *"CURRENT_VERSION=$(date '+%Y.%-m.0')"* ]] } @test "converts from older calver scheme automatically" { @@ -112,7 +119,7 @@ function init_repo { print_run_info [ "$status" -eq 0 ] && - [[ "$output" = *"::set-output name=current-version::2020.9.2"* ]] + [[ "$output" = *"CURRENT_VERSION=2020.9.2"* ]] } @test "strips v from the version" { @@ -124,5 +131,5 @@ function init_repo { print_run_info [ "$status" -eq 0 ] && - [[ "$output" = *"::set-output name=current-version::3.4.5"* ]] + [[ "$output" = *"CURRENT_VERSION=3.4.5"* ]] }