In a typical practical unit test, we seek to test a certain function or method to see how it will react to certain inputs and error conditions. This means that the code of the unit test would need to call the function or method we are trying to test multiple times, and with different inputs and error conditions. Instead of writing large interconnection if statements to make the calls with different inputs, we can instead follow a very popular design pattern known as table-driven development.
The idea behind test-driven development is simple—we will use an array of Go structs or a map to represent our tests. The struct array or map will contain information about the inputs and error conditions that we want to pass ...