Skip to content

Proposal: Remove unit test dependency from MySQL #456

@codingllama

Description

@codingllama

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:

  1. Make tests rely on GetTestDB instead of opening connections directly
  2. Replace the DB with sqlite3/:memory:
  3. ?
  4. 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?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions