From the course: Build a Microservice with Go

Unlock the full course today

Join today to access over 24,100 courses taught by industry experts.

Testing

Testing

- [Instructor] We really didn't talk about testing outside of some manual testing, even though many of the patterns that we used here were used in order to implement testable code. So I'd be remiss if I didn't at least share with you some ideas around testing, and that's what I'd like to do now. So the first area that you might want to start testing is the data layer, and in my opinion it's the hardest place to test in this model. There's really a few options you have. One of them is to utilize a live server. You definitely can put data into your database that allows you to use it for testing, not the best scenario, but better than nothing. You can also do something that I do, which is spin up a docker image containing your database and predefined data, and use that for actually executing your tests. We build our tests with a well-defined docker image. We spin that up unique to each test run. The schema is populated…

Contents