[Catalyst] Using test database with TWAM?

Peter Karman peter at peknet.com
Thu Apr 30 16:12:39 GMT 2009


Jesse Sheidlower wrote on 04/30/2009 10:42 AM:

> Unfortunately I don't know how to do this from a test script,
> and I don't know how to tell TWAM to run a particular app but
> with a different DBIC schema (in this case, the identical one
> but with a different name, pointing to the test db) instead.
> Or how to do the same thing, but with TWAM hitting the app
> with the external-server method (so I can test the Apache
> deployment).
> 
> Would be grateful for any pointers.

Here's what I do.

I have 3 different domains (environments): dev, test and prod. I
indicate which one I want with an environment variable, which defaults
to 'dev' (so if I forget, I only affect development data).

 % MY_DOMAIN=test make test

My base db class (I use RDBO but DBIC would work just as well) checks
that env var and picks a profile to use based on the domain value.

I maintain 3 database instances, one for each domain. I basically take a
dump of my production data via cron on a regular basis, and then import
a recent dump to my test and dev dbs as needed. That's a one-line
system() call in my test scripts in a BEGIN block.

Having the 3 database instances is also nice for schema dev work, as I
can make changes in dev, test them with my code, and then deploy the
changes to test domain, test code, repeat for prod (unless my tests are
somehow destructive of data, in which case I have checks for that env
var in my tests and only run in test/dev.)

HTH

pek

-- 
Peter Karman  .  peter at peknet.com  .  http://peknet.com/




More information about the Catalyst mailing list