I’m very pro “just running the code” when it comes to testing software. But while just spinning up containers does actually “work” – in the sense that the test runs and completes without error. But you very quickly realize that’s clearly not how these things are supposed to work. I’ve been using testcontainers to test the gift registry app I’ve been working on, and it’s been great. I’ve implemented a basic passwordless login setup, and I can test every part of this using live code with the sole exception of actually sending an email via a simple make test. But this was very obviously not the best way to go about it, as you can see from the test output:
Category: Go
-
If you’re going to just run the code, just run the code
-
You can just run the code
So I haven’t made as much progress on the actual gift registry I wanted to write this year, although I do have a Go web application that connects to a Postgres database, with an endpoint that gets the database stats, collects telemetry data, pipes it all to an OpenTelemetry stack, and returns an HTML page with the health check results (server-side rendering is a much more pleasant experience than trying to wrangle Javascript frameworks). I also have tests that confirm this is working. That took a lot longer to set up than I anticipated, but I’m really happy with what I’ve been able to do.
(more…)