Use Docker to test your code! (and a subtle announcement)

Lately I’ve been working on code to unify disparate SQL into a small set of abstractions. There is a lot to do, and while testing generated SQL is nice, actually running that SQL and examining the results is the best way to test the code.

In the past I would have installed a bunch of database engines locally. More recently I’dve used Travis to test against a bunch of databases. I still think that’s a good idea, but pushing to CI to test your code sucks. CI should be for those who forgot to test their code, basically.

So I finally knuckled down and set up a neat little Docker thing to test against PostgreSQL and MySQL. Using a tutorial I wrote a Dockerfile to make a blank PostgreSQL database and I found a mysql one that I could use out of the box.

So now, instead of running my tests with “prove -lr t”, I can do “dockerprove -lr t”, and it will do the same thing, and run against MySQL and PostgreSQL! Awesome!

At some point I’ll do the same thing for DBIx::Introspector, [DBIx::Class](), and maybe others. I’d like to make a more generic tool but I’m struggling with how to do that. Ideas are welcome!

Posted Sat, Feb 22, 2014

Receive Blog Posts in Your Email