mozilla/openbadges-badgekit — pull request #49 by stenington (2013-12-10 16:44:59+00:00)
Title: Separate db for testing

This makes the `db.js` and `badge.js` models take an optional config key, and the tests all pass in `TEST_DATABASE` so production data isn't accidentally clobbered.

One tradeoff I wasn't sure about was the value of having those modules default to `DATABASE` if you don't pass in config. It's less typing while writing app code, but means that someone writing a test lazily could forget to make it use the test database configuration.

Also note that `db.js` now caches the connection for a given key... I wasn't sure if that's how we wanted to do it or not. `badge.js` also attempts to retrieve tables from streamsql's internal cache before defining the full table if that doesn't work.