Skip to content

Commit

Permalink
Add integration test to validate base-url
Browse files Browse the repository at this point in the history
  • Loading branch information
joshmgross committed Nov 16, 2023
1 parent e69ef54 commit babde17
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 2 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,54 @@ 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: Default base-url not set
uses: ./
with:
script: |
const endpoint = github.request.endpoint
return endpoint({}).url
result-encoding: string
- id: base-url-set
name: 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-env
name: base-url does not override GITHUB_API_URL when not set
uses: ./
env:
GITHUB_API_URL: https://my.github-enterprise-server.com/api/v3
with:
script: |
const endpoint = github.request.endpoint
return endpoint({}).url
result-encoding: string
- run: |
echo "- Validating base-url default"
expected="https://api.github.com"
if [[ "${{steps.base-url-default.outputs.result}}" != "$expected" ]]; then
echo $'::error::\u274C' "Expected base-url to start with '$expected', got ${{steps.base-url-default.outputs.result}}"
exit 1
fi
echo "- Validating base-url set to a value"
expected="https://my.github-enterprise-server.com/api/v3"
if [[ "${{steps.base-url-set.outputs.result}}" != "$expected" ]]; then
echo $'::error::\u274C' "Expected base-url to start with '$expected', got ${{steps.base-url-set.outputs.result}}"
exit 1
fi
echo "- Validating base-url not set respects GITHUB_API_URL"
expected="https://my.github-enterprise-server.com/api/v3"
if [[ "${{steps.base-url-env.outputs.result}}" != "$expected" ]]; then
echo $'::error::\u274C' "Expected base-url to start with '$expected', got ${{steps.base-url-env.outputs.result}}"
7 changes: 5 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35509,11 +35509,14 @@ async function main() {
userAgent: userAgent || undefined,
previews: previews ? previews.split(',') : undefined,
retry: retryOpts,
request: requestOpts,
baseUrl: baseUrl || undefined
request: requestOpts
};
if (baseUrl) {
opts.baseUrl = baseUrl;
}
const github = (0,lib_github.getOctokit)(token, opts, plugin_retry_dist_node.retry, dist_node.requestLog);
const script = core.getInput('script', { required: true });
github.request.endpoint('GET /repos/{owner}/{repo}').url;
// Using property/value shorthand on `require` (e.g. `{require}`) causes compilation errors.
const result = await callAsyncFunction({
require: wrapRequire,
Expand Down

0 comments on commit babde17

Please sign in to comment.