Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users

Run catalyst tests against another database

 

 

Catalyst users RSS feed   Index | Next | Previous | View Threaded


jatzger at hotmail

Feb 6, 2010, 2:01 PM

Post #1 of 3 (754 views)
Permalink
Run catalyst tests against another database

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?
Thanks,Jatzger
_________________________________________________________________
Hotmail: Free, trusted and rich email service.
http://clk.atdmt.com/GBL/go/201469228/direct/01/


moseley at hank

Feb 6, 2010, 3:09 PM

Post #2 of 3 (716 views)
Permalink
Re: Run catalyst tests against another database [In reply to]

On Sat, Feb 6, 2010 at 2:01 PM, John Atzger <jatzger [at] hotmail> 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
moseley [at] hank


bobtfish at bobtfish

Feb 6, 2010, 4:37 PM

Post #3 of 3 (711 views)
Permalink
Re: Run catalyst tests against another database [In reply to]

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 [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/

Catalyst users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.