-
Notifications
You must be signed in to change notification settings - Fork 438
Proposal: Remove unit test dependency from MySQL #456
Description
Currently, unit tests require a local MySQL to be running and have a root user without a password. While the presence of MySQL is paramount for integration-like tests, unit tests shouldn't have such requirement. That precludes users from doing a simple go test ./... and forces a specific local configuration.
I've had a quick look at sqlite in memory as substitute for unit tests and it looks viable.
A course of action could be:
- Make tests rely on GetTestDB instead of opening connections directly
- Replace the DB with
sqlite3/:memory: - ?
- Profit
From what I've seen, there a few changes we'd have to make for it to work:
- Remove '#' comments from storage.sql
- Declare indexes separately from table definitions
- Remove
SET GLOBAL sql_mode - Find a way around enums
A simple solution would be to have separate-but-equivalent schemas. That's not entirely desirable due to duplication, but it does fix a whole category of issues. Another venue is to "reinterpret" the script at GetTestDB and remove / change the problematic lines.
There are a few other options, such as writing our own fake storage implementation, but that doesn't solve the issue of storage layer tests.
WDYT?