[Catalyst] Modify config in a test

Bill Moseley moseley at hank.org
Wed Sep 26 13:47:36 GMT 2012


On Wed, Sep 26, 2012 at 1:15 AM, Manni Heumann <heumann at strato-rz.de> wrote:

> Bill Moseley <moseley at hank.org> schrieb am 25.09.2012:
>
> > The app has a myapp.yml config which includes configuration for
> > creating an instance of a Model component -- and part of that Model's
> > config is a database dsn attribute.   When running my test I do want
> > to have the app load this config file -- but I want to modify it
> > on-the-fly.
>
> Why? Why not simply create a myapp_test.yml file and set
> CATALYST_CONFIG_LOCAL_SUFFIX to "test" when you run your test-suite?
>

I guess this is probably the cleanest/easiest.   Create my database and
write out the config in a BEGIN block -- or somehow otherwise delay loading
Catalyst::Test.

My other option could be to create my own instance of the Model object and
then swap it out in the MyApp->components hash.   The fact that my model is
dynamically generated at startup based on config adds a bit of complexity
to it -- but that can be handled.


BTW -- for tests where I need to build a database on-the-fly what I
currently do is set my "make test" config use dsn =3D> 'dbi:Pg' and then set
the PG* environment variables.   But, in this case what I'm doing is
swapping my Postgresql config in my configuration with one to use a SQLite
database in a temporary file just for a few tests.

Thanks for the ideas.


-- =

Bill Moseley
moseley at hank.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20120926/451b6=
85e/attachment.htm


More information about the Catalyst mailing list