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

Validate API key before running unit tests #16

Closed
alexskr opened this issue Nov 17, 2022 · 1 comment
Closed

Validate API key before running unit tests #16

alexskr opened this issue Nov 17, 2022 · 1 comment
Assignees

Comments

@alexskr
Copy link
Member

alexskr commented Nov 17, 2022

Unit tests fail with a confusing and unhelpful error when it is run with an invalid API key. A new unit test should be added to verify that the provided API key validates before proceeding to other unit tests.

relates to #14

@jvendetti jvendetti self-assigned this Jan 10, 2024
@jvendetti
Copy link
Member

The only way I could think of to verify the API key was to issue a simple API request in the base TestCase and check the response, prior to running any of the tests. This led to the interesting discovery that Minitest doesn't have built-in support for something like before(:all), which is discussed in a lot of detail in this issue. I decided to include the minitest-hooks gem, which adds this functionality.

Now if an invalid API key is provided, this is detected and the test suite is aborted, i.e.:

$ ontologies_api_ruby_client git:(master) bundle exec rake test TESTOPTS="-v"
Run options: -v --seed 53341

# Running:

ABORTED! You must provide a valid API key.
rake aborted!
Command failed with status (1)

Fixed by these commits: 4dd08e0, 53f330a

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

No branches or pull requests

2 participants