Adding Actions to a Catalyst app at testing time

November 15th, 2009

In response to a question I posted on the Catalyst list, Tomas Doran (among other suggestions) posted a beautifully devious way to add additional capabilites to your application for test purposes.

When you’re testing with Catalyst::Test and running a local test, you don’t actually fire up a web server and talk over the wire.  It loads your program’s library in to the test script, and calls the functions with the same objects given to it by the other servers.

Your Cat app runs, but all as functions in your program.

Since this is your program – and a test script is just a funny Perl program – you can load libraries and add additional things to the namespace.

Testing Catalyst Session Data

November 15th, 2009

Tomas Doran pointed out the other day, in a post on the Catalyst mailing list, that you could manipulate the session data between test calls if you needed to.

My original question was about manipulating what user was logged by playing with the cookie cache, but it should apply to any value in the session.  You could check them, to see that the internal state of your program is what you think it is, or you could fiddle with them, to test that it does the right things.

Stealing From the Experts: Look at Their Tests!

November 15th, 2009

I don’t know why this didn’t come to me quicker, but I got some good advice on the Catalyst mailing list.  It boils down to “look at how other people do it”, which I usually think of.

What I’d never thought of before was to look at their test cases for ways to do it.

Both Tomas Doran and Peter Karman made good suggestions of places to look for things that would help with my authentication issue.

Cookies and Catalyst::Test

November 15th, 2009

The other day, I asked a question over on the Catalyst mailing list which spurred on some discussion.  Some of that discussion showed up with an example of how to check for cookines on the result of a Catalyst::Test operation.

There seems to be a way to jigger it in, but adding some real support for it might be better. Others seemed to agree.

How?  What’s best?

generic viagra in british columbia Order Viagra can i take viagra

Reinstalling Perl.

October 26th, 2009

The break in my blogging was to start a new job.  It’s kept me incredibly busy.  I’m now a “Senior Infrastructure Architect” and being paid to write and maintain complex Perl scripts.  It means lots more things in Perl to learn and see, but may limit what I can blog about, as I have to be careful of the NDA.  I’m going to try and get back to this blog, though.

I reinstalled Perl the other day.  It was no trouble; it came with my Linux distribution.

Then I had to reinstall all the missing modules.

That should be easy!  I typed ‘autobundle’ in CPAN before I upgraded, and it wrote out a Bundle file.  All should be well!  I should just have to type “perl -MCPAN -e ‘install Bundle::Snapshot_2009_09_09 and let it go do what it needs to do.

Pity it doesn’t work that well.

Read the rest of this entry »

Recursive Dependencies in CPAN

June 20th, 2009

I’ve been quiet lately, as I’ve had hardware problems and haven’t done much development on my spare spare machine.  Finally got a new one, and am installing everything.

Read the rest of this entry »

Autovivification bit me today

May 26th, 2009

For the first time in more than five years, I got bit by autovivification.  It’s one of those odd quirks of Perl that I’d read about, and heard the problems with but never bumped in to them.

Read the rest of this entry »

Perl People are Great!

May 15th, 2009

I have been reading the Catalyst mailing list for a while.  I’m also subscribed to the DBIx::Class mailing list.  These are reasonably busy lists where converstations range from incredibly techincal arguments about ways to refactor the cor to new and confused people sticking their head in and asking questions.  Usually they’re polite and well thought posts from intelligent people.

This is a little different from a lot of Open Source projects!  Read the rest of this entry »

Debugging Catalyst

May 9th, 2009

My last post discussed figuring out how part of Catalyst worked.  I had to put debug code in to a library and watch it run. How do you do tht?

It’s actually pretty easy, but it wasn’t obvious, at least to me.  It is on the debugging page of the Catalyst tutorial, but I missed it the first dozen times I read the page.

Read the rest of this entry »

Catalyst and local configuration files

May 2nd, 2009

This just took me two hours to debug, so I thought I’d go ahead and turn it in to a post…

Summary

Catalyst supports reading a config file. usually called myapp.conf.  You can also add extra configuration, but figuring out where it goes took me ages.

In a nutshell, Catalyst will read myapp.conf and myapp_local.conf.

You can change what the ‘local’ part in that is by setting an environment variable called MYAPP_CONFIG_LOCAL_SUFFIX or one called CATALYST_CONFIG_LOCAL_SUFFIX.

If MYAPP_CONFIG_LOCAL_SUFFIX is set, CATALYST_CONFIG_LOCAL_SUFFIX is apparently ignored.  (You don’t get two additional config files, just the one.)

MYAPP_CONFIG_LOCAL_SUFFIX applies only to MyApp, where CATALYST_CONFIG_LOCAL_SUFFIX will be applied to any Catalyst app.  Be careful with it. Read the rest of this entry »