Verify the testing database before running tests. #1174
Merged
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.
Motivation
Right now when the testing database is not running or has an error to the testing database, we see a lot of test failures on the testing result. By verifying the testing database connection before running the tests, we can guide users by the simple and proper message.
New error message
The actual error message will be like this by this PR when there is an error while connecting to the testing database.
For example, this message is when the database server is not running.
I was inspired for the message content by Bundler error message guiding the actual command line
gem install ...
to make user verify it.Here are also other cases I tested on CI.
Mysql2::Error::ConnectionError: / Access denied for user 'root'@'localhost' (using password: NO)
: the log.Mysql2::Error: / Unknown database 'test'
: the logShowing the message.
I wanted to use the following heredoc to show the message. But I faced the rubocop error on it, I am using
%( ... )
syntax to avoid it.Sorting the before after blocks
I also sorted the before after blocks in the following actually called order.
You can see the called order on the rspec 2.99 document. As the used keywords
:all
,:each
is old unlike the:context
and:example
on the rspec 3 document. I will send another PR to replace the keywords later.