This is duplicated in test/com/puppetlabs/puppetdb/testutils.clj, with slightly different syntax but the concept is the same. I've been using that version in my patch for PDB-341.