forked from nemccarthy/stash-pullrequest-builder-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 55
StashRepository: Merge init() into the constructor #105
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
Conversation
This file contains hidden or 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
jakub-bochenski
requested changes
Jun 21, 2019
src/test/java/stashpullrequestbuilder/stashpullrequestbuilder/StashRepositoryTest.java
Outdated
Show resolved
Hide resolved
Author
|
The requested changes have been made. The unit test is using WireMock now. |
jakub-bochenski
approved these changes
Jun 28, 2019
src/main/java/stashpullrequestbuilder/stashpullrequestbuilder/StashRepository.java
Outdated
Show resolved
Hide resolved
src/main/java/stashpullrequestbuilder/stashpullrequestbuilder/StashRepository.java
Show resolved
Hide resolved
Author
|
Reworked the PR to keep the constructors short. As a side effect, the diff should be easier to read. |
Author
|
Improved the comment for the constructor used in unit tests. |
Author
|
Using Java 8 version of WireMock and dynamic HTTP port for testing. |
Jenkins documentation doesn't guarantee that start() would not be called after run() for a trigger. While it doesn't happen in freestyle projects, Jenkins would actually call start() after run() on the trigger in a pipeline project. That would create a new StashRepository object that would not have the StashApiClient object initialized. When the build completes, it would try to post the build result as a PR comment. That would throw an exception. To prevent it, remove the init() method. Move StashApiClient initialization inside the StashRepository constructor, so that the StashRepository object always has a valid StashApiClient object. Add WireMock as a test dependency. Check that the newly constructed StashRepository object would actually send an HTTP request.
Author
|
Added a verification that WireMock received a GET request. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
That's one of the commits that make pipeline support possible. Extracted from #69 to help with review.
I realize that constructors are less testable than other methods, but the focus here is on fixing an issue with pipelines with minimal changes.
In the future, we can use factory pattern or generics to improve testability. Also, it might be possible not to replace the
StashRepositoryobject on thestart()call for the same job. I'm not doing any optimization at this time, I'm making the code more robust.