-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add tests to verify 'main' overrides 'request'’s default 'baseU…
…rl' only when 'GITHUB_API_URL' is set
- Loading branch information
Showing
7 changed files
with
115 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Verify `main` overrides `request`’s default `baseUrl` when `GITHUB_API_URL` is set. | ||
// @ts-check | ||
|
||
import esmock from "esmock"; | ||
|
||
process.env.GITHUB_REPOSITORY = "actions/create-github-app-token"; | ||
process.env.GITHUB_API_URL = "https://github.acme-inc.com/api/v3"; | ||
|
||
// inputs are set as environment variables with the prefix INPUT_ | ||
// https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#example-specifying-inputs | ||
process.env.INPUT_APP_ID = "123456"; | ||
process.env.INPUT_PRIVATE_KEY = `-----BEGIN RSA PRIVATE KEY----- | ||
ABC/def/123== | ||
-----END RSA PRIVATE KEY-----`; | ||
|
||
await esmock("../main.js", { | ||
"../lib/main.js": { | ||
main: async ( | ||
_appId, | ||
_privateKey, | ||
_repository, | ||
_core, | ||
_createAppAuth, | ||
request | ||
) => { | ||
console.log(request.endpoint.DEFAULTS.baseUrl); | ||
console.log(request.endpoint.DEFAULTS.headers["user-agent"]); | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Verify `main` doesn’t override `request`’s default `baseUrl` when `GITHUB_API_URL` isn’t set. | ||
// @ts-check | ||
|
||
import esmock from "esmock"; | ||
|
||
process.env.GITHUB_REPOSITORY = "actions/create-github-app-token"; | ||
delete process.env.GITHUB_API_URL; | ||
|
||
// inputs are set as environment variables with the prefix INPUT_ | ||
// https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#example-specifying-inputs | ||
process.env.INPUT_APP_ID = "123456"; | ||
process.env.INPUT_PRIVATE_KEY = `-----BEGIN RSA PRIVATE KEY----- | ||
ABC/def/123== | ||
-----END RSA PRIVATE KEY-----`; | ||
|
||
await esmock("../main.js", { | ||
"../lib/main.js": { | ||
main: async ( | ||
_appId, | ||
_privateKey, | ||
_repository, | ||
_core, | ||
_createAppAuth, | ||
request | ||
) => { | ||
console.log(request.endpoint.DEFAULTS.baseUrl); | ||
console.log(request.endpoint.DEFAULTS.headers["user-agent"]); | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.