Skip to content

test(release): add unit tests when searching for a release #603

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 18, 2025

Conversation

rwaskiewicz
Copy link
Contributor

@rwaskiewicz rwaskiewicz commented Apr 4, 2025

when a release with the desired tag_name is found, break out of the loop
that looks for it. this prevents the case where accidentally overwrite a
detected release on successive iterations of the for loop

Note: I was unsure if I should/not include an update to the build. If you're willing to accept this PR and prefer to update dist yourself, the build update is in a separate commit for an easy git revert

fixes: #602

when a release with the desired tag_name is found, break out of the loop
that looks for it. this prevents the case where accidentally overwrite a
detected release on successive iterations of the for loop

fixes: softprops#602
add tests for updated functionality to break when we find a release.
the logic has been extracted into its own function, to make testing
simpler by avoiding over mocking/stubbing of network calls that would
create or update a release.

the tests that were added use jest's describe/it blocks, but use node's
assert function to align with other tests. there isn't any prior art for
mocking function calls in the codebase, so for now we use simple promises
in "mock" objects that adhere to the Releaser interface
purely a sytlistic choice to not have to pre-declare the _release variable,
and not have to check using `typeof _release === "string"` when detecting
a found release
@rwaskiewicz rwaskiewicz changed the title fix(release): break when draft release is found test(release): add unit tests when searching for a release Apr 16, 2025
@chenrui333
Copy link
Collaborator

@rwaskiewicz thanks for the work! <3

@chenrui333 chenrui333 merged commit 6b18c2f into softprops:master Apr 18, 2025
1 check passed
@rwaskiewicz rwaskiewicz deleted the rw/break-on-found-release branch April 19, 2025 00:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiple Draft Releases Created when >100 Releases Exist in GitHub
3 participants