-
Notifications
You must be signed in to change notification settings - Fork 1
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
Open source tasks + tests refactoring #2
Conversation
…dd-files into open-source-tasks
This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation. |
Could you elaborate more on this? I don't think I understand why it is better to be invoked elsewhere since there is nothing different in how it is created when it is made in any other function.
Actually the delete branch logic hasn't been refactored so it shouldn't be creating a client anyways. That codebase wasn't touched as part of my first round refactoring which is why it has the old logic in it |
@therealkujo replies below
Sure. It was not possible to stub API responses because the GitHub Client was assigned inside of the functions. By removing it and passing it in as a parameter it becomes more dynamix - i.e you can pass in a stubbed client or it can be the GitHub Client. For testing, the
Sure, it doesn't change the fact that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this! There are some minor grammar changes I found.
Other than this, I wanted to get your thoughts before approving this. I really like that we are mocking everything but also wonder if we should have the ability to do an actual run as well? In the event the GitHub APIs change, how would we be able to catch that in our tests? Might be nice to be able to periodically run our tests live on the production branch to ensure that nothing is broken but be able to use all the mocks for PR reviews.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 Thanks for working on this!
What does this pull request accomplish?
Client
parameters. This results in a better function signature all around because theClient
becomes dynamic rather than statically assigned in the method. It also removes duplication, for example, in the delete branch logic we were duplicating the creation of the client by having logic as follows:This pattern is easy to fall into if the Client is not parameterized. Therefore, the refactor addressed both test stubbing and logical errors.
For the test stubbing, I created a mock TestClient and stubbed API responses.