[Catalyst] Using test database with TWAM?
Jesse Sheidlower
jester at panix.com
Thu Apr 30 19:10:13 GMT 2009
On Thu, Apr 30, 2009 at 11:12:39AM -0500, Peter Karman wrote:
> 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.
And Zbigniew Lukasiak wrote:
> Hmm - first question why a different DBIC schema? Why not use the
> same schema only connected to a different dsn?
> And if you go that path - then you can move the connection details
> (dsn) from the Catalyst model code into a config file. The final step
> would be to use different config files for the tests and for the real
> app.
Thanks--this is all very useful. I do not, in fact, have any
reason for a different schema; a different DSN is all I need.
I do keep the connection details in a config file.
I guess my question then becomes the more prosaic one of
detail, esp. as I haven't really done much with tests before:
How do I populate this database from within my test script?
How do I get my test script to use a different config file for
the test database? And Catalyst-wise, how do I run TWAM
against the version of my app that's using this other
config-file setup, either from the test server, or externally?
Thanks. I do know there's the bit in the Testing tutorial
about using a test database, but the larger-scale things
weren't really addressed. (I'll add them to the Tutorial, if I
get good answers!)
Jesse
More information about the Catalyst
mailing list