[Catalyst] Using test database with TWAM?

Matt S Trout dbix-class at trout.me.uk
Thu Apr 30 22:38:18 GMT 2009


On Thu, Apr 30, 2009 at 11:42:39AM -0400, Jesse Sheidlower wrote:
> 
> I assume this is more of a general Perl testing question than
> a Catalyst question, but....
> 
> I finally sat down to write real tests for one of my apps,
> with the hopes that I'll do this regularly for everything. I
> was using the Tutorial chapter on testing, and the docs for
> Test::WWW::Mechanize::Catalyst, for ideas.
> 
> I quickly hit a wall because I couldn't figure out how to run
> this with a test database. Since I need to test modification
> and deletion stuff, but have real data, I can't just run this
> against my actual app. So I figured I would dump the sql from
> my production app and have my test program load this into a
> database called "test-db" or whatever, having the same format
> and schema as the real db, and then just drop the test db at
> the end of the test.

You want DBIx::Class::Fixtures for the dump/load crap, and DBIC's ->deploy
method for the "dump/create the tables" stuff. Hop onto the dbix-class
list if you get stuck with that part.

> 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)

Then you want to read the ConfigLoader docs and search for LOCAL_SUFFIX for
how to define a testing config.

-- 
        Matt S Trout         Catalyst and DBIx::Class consultancy with a clue
     Technical Director      and a commit bit: http://shadowcat.co.uk/catalyst/
 Shadowcat Systems Limited
  mst (@) shadowcat.co.uk        http://shadowcat.co.uk/blog/matt-s-trout/



More information about the Catalyst mailing list