Skip to content
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

Unit tests to prevent bad commits to pass #11

Open
TheAssassin opened this issue Nov 6, 2017 · 1 comment
Open

Unit tests to prevent bad commits to pass #11

TheAssassin opened this issue Nov 6, 2017 · 1 comment

Comments

@TheAssassin
Copy link
Contributor

As seen in #10, some bugs might pass, leading to broken builds. We should add some tests.

There is no real "dummy" or "sandbox" GitHub API (like there is one for many other REST APIs, e.g. https://developer.paypal.com/docs/integration/direct/payments/test-the-api/), so the question is how to realize the tests.

In an example from the GitHub API docs they just have an extra repository whose sole purpose is to serve as a sandbox for API calls. However, I don't think that's really practicable, it'll generate a lot of unnecessary notifications etc.

An alternative is to set up a fake API server as a fixture for the tests. There's a bunch of possibilities, e.g., https://github.com/localmed/api-mock, https://github.com/typicode/json-server or https://github.com/basicallydan/interfake (did not test any of them, just the result of some searches). Also, we could roll our own based on a little Flask script.

Both options have pros and cons -- the real GitHub API will always provide the most realistic experience, whereas a fake API might not react to changes in the GitHub API spec in time. I'd probably go with writing a little Flask based API server, and redirect all the API calls to that service (e.g., by making the API address upload.sh uses configurable using an environment variable).

A tool used as widely as this one has to work reliably. And we all know untested code is broken code.

@probonopd
Copy link
Owner

A further alternative would be to copy the script into another project, do the changes there and use it for a while, and only thereafter make the changes here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants