| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -248,3 +248,78 @@ jobs: | |||
| 248 | 248 | done <<< "$tests" | |
| 249 | 249 | ||
| 250 | 250 | 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 | + - run: | | ||
| 298 | + echo "- Validating API URL default" | ||
| 299 | + expected="https://api.github.com/" | ||
| 300 | + actual="${{steps.base-url-default.outputs.result}}" | ||
| 301 | + if [[ "$expected" != "$actual" ]]; then | ||
| 302 | + echo $'::error::\u274C' "Expected base-url to equal '$expected', got $actual" | ||
| 303 | + exit 1 | ||
| 304 | + fi | ||
| 305 | + echo "- Validating GraphQL URL default" | ||
| 306 | + expected="https://api.github.com/graphql" | ||
| 307 | + actual="${{steps.base-url-default-graphql.outputs.result}}" | ||
| 308 | + if [[ "$expected" != "$actual" ]]; then | ||
| 309 | + echo $'::error::\u274C' "Expected base-url to equal '$expected', got $actual" | ||
| 310 | + exit 1 | ||
| 311 | + fi | ||
| 312 | + echo "- Validating base-url set to a value" | ||
| 313 | + expected="https://my.github-enterprise-server.com/api/v3/" | ||
| 314 | + actual="${{steps.base-url-set.outputs.result}}" | ||
| 315 | + if [[ "$expected" != "$actual" ]]; then | ||
| 316 | + echo $'::error::\u274C' "Expected base-url to equal '$expected', got $actual" | ||
| 317 | + exit 1 | ||
| 318 | + fi | ||
| 319 | + echo "- Validating GraphQL URL with base-url set to a value" | ||
| 320 | + expected="https://my.github-enterprise-server.com/api/v3/graphql" | ||
| 321 | + actual="${{steps.base-url-set-graphql.outputs.result}}" | ||
| 322 | + if [[ "$expected" != "$actual" ]]; then | ||
| 323 | + echo $'::error::\u274C' "Expected base-url to equal '$expected', got $actual" | ||
| 324 | + exit 1 | ||
| 325 | + fi | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35509,9 +35509,13 @@ async function main() { | |||
| 35509 | 35509 | userAgent: userAgent || undefined, | |
| 35510 | 35510 | previews: previews ? previews.split(',') : undefined, | |
| 35511 | 35511 | retry: retryOpts, | |
| 35512 | - request: requestOpts, | ||
| 35513 | - baseUrl: baseUrl || undefined | ||
| 35512 | + request: requestOpts | ||
| 35514 | 35513 | }; | |
| 35514 | + // Setting `baseUrl` to undefined will prevent the default value from being used | ||
| 35515 | + // https://github.com/actions/github-script/issues/436 | ||
| 35516 | + if (baseUrl) { | ||
| 35517 | + opts.baseUrl = baseUrl; | ||
| 35518 | + } | ||
| 35515 | 35519 | const github = (0,lib_github.getOctokit)(token, opts, plugin_retry_dist_node.retry, dist_node.requestLog); | |
| 35516 | 35520 | const script = core.getInput('script', { required: true }); | |
| 35517 | 35521 | // Using property/value shorthand on `require` (e.g. `{require}`) causes compilation errors. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -44,8 +44,13 @@ async function main(): Promise<void> { | |||
| 44 | 44 | userAgent: userAgent || undefined, | |
| 45 | 45 | previews: previews ? previews.split(',') : undefined, | |
| 46 | 46 | retry: retryOpts, | |
| 47 | - request: requestOpts, | ||
| 48 | - baseUrl: baseUrl || undefined | ||
| 47 | + request: requestOpts | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + // Setting `baseUrl` to undefined will prevent the default value from being used | ||
| 51 | + // https://github.com/actions/github-script/issues/436 | ||
| 52 | + if (baseUrl) { | ||
| 53 | + opts.baseUrl = baseUrl | ||
| 49 | 54 | } | |
| 50 | 55 | ||
| 51 | 56 | const github = getOctokit(token, opts, retry, requestLog) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments