Closed smockle closed 11 months ago
I prefer we don't use any module mocking…
👍 Cool; removed esmock
and tests using module mocks, in https://github.com/smockle/create-github-app-token/pull/56/commits/60504269230a68706c8bf9ed9e40ced513146235.
…instead mock all requests and capture and snapshot all logs / thrown errors.…
I added a happy path test (that mocks requests and validates stdout), in https://github.com/smockle/create-github-app-token/pull/56/commits/43f24998742aeb378c1e91e0fe6a0d790a0a6b92. @gr2m, is that what you had in mind?
I added a happy path test (that mocks requests and validates stdout), in 43f2499. @gr2m, is that what you had in mind?
Yes, I just looked at it, looks good 👍🏼 Thank you!
This PR is in draft, but as a quick update: After rebasing, npm test
exits with an error. I’m working on debugging that.
🤔 I’m not sure why the test / Integration (pull_request) check is failing; npm test
passes on my machine.
Update: Ah, I now suspect the issue is that @actions/core
performs differently in the Actions runner environment, vs locally, i.e. logs different things.
Update: Yup, that was indeed the root of the issue. Fixed in https://github.com/actions/create-github-app-token/pull/56/commits/10b4ea239df850e8fb91ed8e44cfca3c2a3ecd89.
Update: Ah, I now suspect the issue is that
@actions/core
performs differently in the Actions runner environment, vs locally, i.e. logs different things.
That may be why some projects mock core
in their tests, e.g. actions/checkout
. Semi-related: https://github.com/actions/toolkit/issues/118.
Ah, no, actually, there’s a subtle bug with the code that returns an installation access token (it’s missing the response header that makes it an object). The runner warns about this; local does not. That’s probably the source of the error.
Update: Fixed this in https://github.com/actions/create-github-app-token/pull/56/commits/1174dffe76b61cd790fb19509a55798c3e502285 and https://github.com/actions/create-github-app-token/pull/56/commits/73aade40a73493ad1ca8464a050882453ed10b9e.
:tada: This PR is included in version 1.5.0 :tada:
The release is available on GitHub release
Your semantic-release bot :package::rocket:
Part of https://github.com/actions/create-github-app-token/issues/43
This PR adds tests for
main.js
, similar to the tests that already exist forpost.js
.Specifically, it tests that:
main
exits with an error whenGITHUB_REPOSITORY
is missing.main
exits with an error whenGITHUB_REPOSITORY_OWNER
is missing.main
successfully obtains a token when…owner
andrepositories
inputs are set (and the latter is a single repo).owner
andrepositories
inputs are set (and the latter is a list of repos).owner
input is set (to an org), but therepositories
input isn’t set.owner
input is set (to a user), but therepositories
input isn’t set.owner
input is not set, but therepositories
input is set.owner
norrepositories
input is set.❧
Architecturally, in order to keep individual tests concise, this PR adds
tests/main.js
, which:main.js
itself.The
tests/main-token-get-*.test.js
test files runtests/main.js
with various scenario-specific callback functions.