[Catalyst-dev] subdomain hook for Catalyst::Test

Matt S Trout dbix-class at trout.me.uk
Sun Sep 28 14:17:54 BST 2008


On Wed, Sep 17, 2008 at 06:12:48PM -0400, Jason Gottshall wrote:
> Our app allows for virtual subdomains that (among other things) enable 
> specific behaviors in the app.
> 
> For example,
>   http://www.myapp.com/foo/bar
> and
>   http://magic.myapp.com/foo/bar
> both point to same app, but the latter has "magic" behaviors associated 
> with it.
> 
> The problem is that we're having trouble writing tests against specific 
> behaviors in our controller tests, particularly when we want to test 
> several different subdomains within the same script.
> 
> My current solution is to set an environment variable in the test script 
> specifing the desired subdomain. I've added hooks to the app that will 
> use this value if available, so that controller tests using a "local" 
> instance of the app instantiated with Catalyst::Test and a faked request 
> will Just Work. But we run into trouble when we try to run the tests 
> against a "remote" server by setting CATALYST_SERVER. The env var 
> setting embedded in the script obviously is not visible to the server 
> instance that's running remotely.
> 
> In order to remedy this problem, I've patched Catalyst::Test to look for 
> my new env var and prepend it to the CATALYST_SERVER host component. It 
> works great! But I'm wondering whether this patch is worthy of adding to 
> the core, or if there's a different way I should be approaching the 
> problem. Here's a diff against 5.70/trunk:

Could we not make request() take the domain or something?

It's currently single argument so adding an options hashref would be fine,
plus maybe some way to provide default values therefore in the cases where
we're doing request() from inside other code?

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/            http://www.shadowcat.co.uk/servers/



More information about the Catalyst-dev mailing list