Posts

Showing posts from September, 2019

Unit Test Database Mocking in Golang is Killing Me!

For some reason, writing a particular set of unit tests in Golang proved to be an extreme hassle.  In this case, I was trying to add a column to a table and then write a unit test to verify this new functionality.   No matter how much I looked around for where to correctly specify how to build this table with the new column, the Cassandra database kept complaining the column didn’t exist.   Imagine how frustrating it is to specify a relational database schema that seems to be ignored by your unit tests. Background Our system consists of a Cassandra database plus a Go backend server.   The Go unit tests require Cassandra to be running locally on a Docker container, but do not seem to actually utilize the existing databases, opting to make its own that is out of reach from anything I can see from TablePlus.   The Go code itself utilizes these objects through some level of indirection by a manager, a harness, and a couple modules dealing in the actual queries. The Fix