Skip to content

Commit 4793596

Browse files
committed
Add integration test to validate base-url
1 parent e69ef54 commit 4793596

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

.github/workflows/integration.yml

+51
Original file line numberDiff line numberDiff line change
@@ -248,3 +248,54 @@ jobs:
248248
done <<< "$tests"
249249
250250
echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY
251+
252+
test-base-url:
253+
name: 'Integration test: base-url option'
254+
runs-on: ubuntu-latest
255+
steps:
256+
- uses: actions/checkout@v3
257+
- uses: ./.github/actions/install-dependencies
258+
- id: base-url-default
259+
name: Default base-url not set
260+
uses: ./
261+
with:
262+
script: |
263+
const endpoint = github.request.endpoint
264+
return endpoint({}).url
265+
result-encoding: string
266+
- id: base-url-set
267+
name: base-url set
268+
uses: ./
269+
with:
270+
base-url: https://my.github-enterprise-server.com/api/v3
271+
script: |
272+
const endpoint = github.request.endpoint
273+
return endpoint({}).url
274+
result-encoding: string
275+
- id: base-url-env
276+
name: base-url does not override GITHUB_API_URL when not set
277+
uses: ./
278+
env:
279+
GITHUB_API_URL: https://my.github-enterprise-server.com/api/v3
280+
with:
281+
script: |
282+
const endpoint = github.request.endpoint
283+
return endpoint({}).url
284+
result-encoding: string
285+
- run: |
286+
echo "- Validating base-url default"
287+
expected="https://api.github.com"
288+
if [[ "${{steps.base-url-default.outputs.result}}" != "$expected" ]]; then
289+
echo $'::error::\u274C' "Expected base-url to start with '$expected', got ${{steps.base-url-default.outputs.result}}"
290+
exit 1
291+
fi
292+
echo "- Validating base-url set to a value"
293+
expected="https://my.github-enterprise-server.com/api/v3"
294+
if [[ "${{steps.base-url-set.outputs.result}}" != "$expected" ]]; then
295+
echo $'::error::\u274C' "Expected base-url to start with '$expected', got ${{steps.base-url-set.outputs.result}}"
296+
exit 1
297+
fi
298+
echo "- Validating base-url not set respects GITHUB_API_URL"
299+
expected="https://my.github-enterprise-server.com/api/v3"
300+
if [[ "${{steps.base-url-env.outputs.result}}" != "$expected" ]]; then
301+
echo $'::error::\u274C' "Expected base-url to start with '$expected', got ${{steps.base-url-env.outputs.result}}"

0 commit comments

Comments
 (0)