Use testcontainers to spawn MySQL server container in unit tests. by arthurschreiber · Pull Request #1457 · github/gh-ost

Description

Unit tests in gh-ost are pretty basic right now. They often only verify simple behaviour like query generation, but fall short of testing more complex behaviours like actually running the changelog applier, because those require an actual MySQL instance to be running, and then might also depend on the exact settings of that instance, which we might not even have control over.

By using testcontainers-go, we can spawn MySQL containers using exactly the settings we want to test.

This adds a few simple test cases to the Applier tests that show how this could work.

In case this PR introduced Go code changes:

  • contributed code is using same conventions as original code
  • script/cibuild returns with no formatting errors, build errors or unit test errors.