Re: [Catalyst] Run catalyst tests against another database

2010-02-06 Thread Bill Moseley
On Sat, Feb 6, 2010 at 2:01 PM, John Atzger jatz...@hotmail.com wrote:

  I want my Catalyst tests to run against a test database.  I wrote this:

   package MyApp::Model::DB;
   use strict;
   use base 'Catalyst::Model::DBIC::Schema';

   BEGIN {
 require MyApp;
 my $db = $ENV{HARNESS_ACTIVE} ? 'test' : 'myapp';
 my $config = MyApp-config-{database}{$db};

 __PACKAGE__-config(
 schema_class = 'MyApp::Schema',
 connect_info = {
   dsn = $config-{dsn},
   user = $config-{user},
   password = $config-{password},
 );
   }

 I don't want test information in my code. How do people do this?


I use separate config files that get merged into the main config.



-- 
Bill Moseley
mose...@hank.org
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Run catalyst tests against another database

2010-02-06 Thread Tomas Doran


On 6 Feb 2010, at 22:01, John Atzger wrote:

I don't want test information in my code. How do people do this?


Just make your tests set the MYAPP_CONFIG environment variable to  
point at a test configuration with different DB details.


e.g. 
http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits/Gitalist.git;a=blob;f=t/lib/TestGitalist.pm;h=05a20640efdb67b1dfe0c1572dba6713443a7be7;hb=less_fugly_uris

Cheers
t0m


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/