mirror of
https://github.com/SonarSource/sonarqube-quality-gate-action.git
synced 2026-10-07 12:21:31 +00:00
SQQGGHA-5 Ambiguous redirect when GITHUB_OUTPUT is not set (#33)
This commit is contained in:
1 parent
745e48ebda
commit
d304d050d9
3 files changed
+68
-4
No files matched your search
@@ -192,3 +192,58 @@ teardown() {
|
||||
[[ "${lines[0]}" = "....." ]]
|
||||
[[ "${lines[1]}" = *"Quality Gate has PASSED."* ]]
|
||||
}
|
||||
|
||||
@test "pass spaces in GITHUB_OUTPUT path are handled" {
|
||||
export SONAR_TOKEN="test"
|
||||
echo "serverUrl=http://localhost:9000" >> metadata_tmp
|
||||
echo "ceTaskUrl=http://localhost:9000/api/ce/task?id=AXlCe3gsFwOUsY8YKHTn" >> metadata_tmp
|
||||
|
||||
#mock curl
|
||||
function curl() {
|
||||
url="${@: -1}"
|
||||
if [[ $url == *"/api/qualitygates/project_status?analysisId"* ]]; then
|
||||
echo '{"projectStatus":{"status":"OK"}}'
|
||||
else
|
||||
echo '{"task":{"analysisId":"AXlCe3jz9LkwR9Gs0pBY","status":"SUCCESS"}}'
|
||||
fi
|
||||
}
|
||||
export -f curl
|
||||
|
||||
# GITHUB_OUTPUT is a path with spaces
|
||||
github_output_dir="${BATS_TEST_TMPDIR}/some subdir"
|
||||
mkdir -p "${github_output_dir}"
|
||||
export GITHUB_OUTPUT="${github_output_dir}/github_output"
|
||||
touch "${GITHUB_OUTPUT}"
|
||||
|
||||
run script/check-quality-gate.sh metadata_tmp
|
||||
|
||||
read -r github_out_actual < "${GITHUB_OUTPUT}"
|
||||
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "${github_out_actual}" = "quality-gate-status=PASSED" ]]
|
||||
[[ "$output" = *"Quality Gate has PASSED."* ]]
|
||||
}
|
||||
|
||||
@test "pass fall back to set-output if GITHUB_OUTPUT unset" {
|
||||
export SONAR_TOKEN="test"
|
||||
unset GITHUB_OUTPUT
|
||||
echo "serverUrl=http://localhost:9000" >> metadata_tmp
|
||||
echo "ceTaskUrl=http://localhost:9000/api/ce/task?id=AXlCe3gsFwOUsY8YKHTn" >> metadata_tmp
|
||||
|
||||
#mock curl
|
||||
function curl() {
|
||||
url="${@: -1}"
|
||||
if [[ $url == *"/api/qualitygates/project_status?analysisId"* ]]; then
|
||||
echo '{"projectStatus":{"status":"OK"}}'
|
||||
else
|
||||
echo '{"task":{"analysisId":"AXlCe3jz9LkwR9Gs0pBY","status":"SUCCESS"}}'
|
||||
fi
|
||||
}
|
||||
export -f curl
|
||||
|
||||
run script/check-quality-gate.sh metadata_tmp
|
||||
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" = *"::set-output name=quality-gate-status::PASSED"* ]]
|
||||
[[ "$output" = *"Quality Gate has PASSED."* ]]
|
||||
}
|
||||
Reference in new issue
Block a user