@@ -248,3 +248,119 @@ 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+
259+ - id : base-url-default
260+ name : API URL with base-url not set
261+ uses : ./
262+ with :
263+ script : |
264+ const endpoint = github.request.endpoint
265+ return endpoint({}).url
266+ result-encoding : string
267+
268+ - id : base-url-default-graphql
269+ name : GraphQL URL with base-url not set
270+ uses : ./
271+ with :
272+ script : |
273+ const endpoint = github.request.endpoint
274+ return endpoint({url: "/graphql"}).url
275+ result-encoding : string
276+
277+ - id : base-url-set
278+ name : API URL with base-url set
279+ uses : ./
280+ with :
281+ base-url : https://my.github-enterprise-server.com/api/v3
282+ script : |
283+ const endpoint = github.request.endpoint
284+ return endpoint({}).url
285+ result-encoding : string
286+
287+ - id : base-url-set-graphql
288+ name : GraphQL URL with base-url set
289+ uses : ./
290+ with :
291+ base-url : https://my.github-enterprise-server.com/api/v3
292+ script : |
293+ const endpoint = github.request.endpoint
294+ return endpoint({url: "/graphql"}).url
295+ result-encoding : string
296+
297+ - id : base-url-env
298+ name : base-url does not override API URL when not set
299+ uses : ./
300+ env :
301+ GITHUB_API_URL : https://my.github-enterprise-server.com/api/v3
302+ with :
303+ script : |
304+ const endpoint = github.request.endpoint
305+ return endpoint({}).url
306+ result-encoding : string
307+
308+ - id : base-url-env-graphql
309+ name : base-url does not override GraphQL URL when not set
310+ uses : ./
311+ env :
312+ GITHUB_API_URL : https://my.github-enterprise-server.com/api/v3
313+ with :
314+ script : |
315+ const endpoint = github.request.endpoint
316+ return endpoint({url: "/graphql"}).url
317+ result-encoding : string
318+
319+ - run : |
320+ echo "- Validating API URL default"
321+ expected="https://api.github.com/"
322+ actual="${{steps.base-url-default.outputs.result}}"
323+ if [[ "$expected" != "$actual" ]]; then
324+ echo $'::error::\u274C' "Expected base-url to equal '$expected', got $actual"
325+ exit 1
326+ fi
327+
328+ echo "- Validating GraphQL URL default"
329+ expected="https://api.github.com/graphql"
330+ actual="${{steps.base-url-default-graphql.outputs.result}}"
331+ if [[ "$expected" != "$actual" ]]; then
332+ echo $'::error::\u274C' "Expected base-url to equal '$expected', got $actual"
333+ exit 1
334+ fi
335+
336+ echo "- Validating base-url set to a value"
337+ expected="https://my.github-enterprise-server.com/api/v3/"
338+ actual="${{steps.base-url-set.outputs.result}}"
339+ if [[ "$expected" != "$actual" ]]; then
340+ echo $'::error::\u274C' "Expected base-url to equal '$expected', got $actual"
341+ exit 1
342+ fi
343+
344+ echo "- Validating GraphQL URL with base-url set to a value"
345+ expected="https://my.github-enterprise-server.com/api/v3/graphql"
346+ actual="${{steps.base-url-set-graphql.outputs.result}}"
347+ if [[ "$expected" != "$actual" ]]; then
348+ echo $'::error::\u274C' "Expected base-url to equal '$expected', got $actual"
349+ exit 1
350+ fi
351+
352+ echo "- Validating API URL with base-url not set respects GITHUB_API_URL"
353+ expected="https://my.github-enterprise-server.com/api/v3/"
354+ actual="${{steps.base-url-env.outputs.result}}"
355+ if [[ "$expected" != "$actual" ]]; then
356+ echo $'::error::\u274C' "Expected base-url to equal '$expected', got $actual"
357+ exit 1
358+ fi
359+
360+ echo "- Validating GraphQL URL with base-url not set respects GITHUB_API_URL"
361+ expected="https://my.github-enterprise-server.com/api/v3/graphql"
362+ actual="${{steps.base-url-env-graphql.outputs.result}}"
363+ if [[ "$expected" != "$actual" ]]; then
364+ echo $'::error::\u274C' "Expected base-url to equal '$expected', got $actual"
365+ exit 1
366+ fi
0 commit comments