mirror of
https://github.com/actions/github-script.git
synced 2025-12-08 08:06:23 +00:00
Avoid setting baseUrl to undefined when input is not provided
This commit is contained in:
75
.github/workflows/integration.yml
vendored
75
.github/workflows/integration.yml
vendored
@@ -248,3 +248,78 @@ jobs:
|
||||
done <<< "$tests"
|
||||
|
||||
echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY
|
||||
|
||||
test-base-url:
|
||||
name: 'Integration test: base-url option'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: ./.github/actions/install-dependencies
|
||||
|
||||
- id: base-url-default
|
||||
name: API URL with base-url not set
|
||||
uses: ./
|
||||
with:
|
||||
script: |
|
||||
const endpoint = github.request.endpoint
|
||||
return endpoint({}).url
|
||||
result-encoding: string
|
||||
|
||||
- id: base-url-default-graphql
|
||||
name: GraphQL URL with base-url not set
|
||||
uses: ./
|
||||
with:
|
||||
script: |
|
||||
const endpoint = github.request.endpoint
|
||||
return endpoint({url: "/graphql"}).url
|
||||
result-encoding: string
|
||||
|
||||
- id: base-url-set
|
||||
name: API URL with base-url set
|
||||
uses: ./
|
||||
with:
|
||||
base-url: https://my.github-enterprise-server.com/api/v3
|
||||
script: |
|
||||
const endpoint = github.request.endpoint
|
||||
return endpoint({}).url
|
||||
result-encoding: string
|
||||
|
||||
- id: base-url-set-graphql
|
||||
name: GraphQL URL with base-url set
|
||||
uses: ./
|
||||
with:
|
||||
base-url: https://my.github-enterprise-server.com/api/v3
|
||||
script: |
|
||||
const endpoint = github.request.endpoint
|
||||
return endpoint({url: "/graphql"}).url
|
||||
result-encoding: string
|
||||
|
||||
- run: |
|
||||
echo "- Validating API URL default"
|
||||
expected="https://api.github.com/"
|
||||
actual="${{steps.base-url-default.outputs.result}}"
|
||||
if [[ "$expected" != "$actual" ]]; then
|
||||
echo $'::error::\u274C' "Expected base-url to equal '$expected', got $actual"
|
||||
exit 1
|
||||
fi
|
||||
echo "- Validating GraphQL URL default"
|
||||
expected="https://api.github.com/graphql"
|
||||
actual="${{steps.base-url-default-graphql.outputs.result}}"
|
||||
if [[ "$expected" != "$actual" ]]; then
|
||||
echo $'::error::\u274C' "Expected base-url to equal '$expected', got $actual"
|
||||
exit 1
|
||||
fi
|
||||
echo "- Validating base-url set to a value"
|
||||
expected="https://my.github-enterprise-server.com/api/v3/"
|
||||
actual="${{steps.base-url-set.outputs.result}}"
|
||||
if [[ "$expected" != "$actual" ]]; then
|
||||
echo $'::error::\u274C' "Expected base-url to equal '$expected', got $actual"
|
||||
exit 1
|
||||
fi
|
||||
echo "- Validating GraphQL URL with base-url set to a value"
|
||||
expected="https://my.github-enterprise-server.com/api/v3/graphql"
|
||||
actual="${{steps.base-url-set-graphql.outputs.result}}"
|
||||
if [[ "$expected" != "$actual" ]]; then
|
||||
echo $'::error::\u274C' "Expected base-url to equal '$expected', got $actual"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user