On 9/14/05, John Krystynak <[EMAIL PROTECTED]> wrote:
> I have a maypole application that has a Config class, which specifies
> the dsn/user/pass like so:
>
> Config.pm:
> MyApp->config->{dsn} = "dbi:mysql:bla";
> MyApp->config->{user} = "user";
> MyApp->config->{pass} = "pass";
>
> The dbi connect call happens in MyApp::DBI.pm:
>
> package MyApp::DBI;
> use base qw(Class::DBI::mysql);
> MyApp::DBI->connection(MyApp->config->{dsn},
> MyApp->config->{user},
> MyApp->config->{pass});
> MyApp::DBI->autoupdate(1);
>
> I want to test MyApp against a dummy database - i.e. using a different
> dbi connection in my tests.
>
> Since my package that uses Maypole::Application then pulls in my
> Config class, and then calls setup.
>
> package MyApp;
> use URI;
> use Maypole::Application qw(-Debug Authentication::UserSessionCookie);
> use MyApp::Config;
> use MyApp::DBI;
> use MyApp::User;
> ...
>
> MyApp->config->model("Maypole::Model::CDBI::Plain");
> MyApp->setup([qw/MyApp::User...
>
> I can't find out how I can set the dsn to be different in my test class.
>
> Is there any modular way from a test to reset the database connection
> to my test database/user? How could I structure it so the
> dsn/user/pass info was able to be changed?
Use environment variables. Set $ENV{TESTING} = 1 in your test scripts,
then set dsn, user, pass etc in your config according to that.
d.
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Maypole-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/maypole-users