Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Localhost network interaction in tests

by Corion (Pope)
on Jan 01, 2012 at 17:40 UTC ( #945798=note: print w/replies, xml ) Need Help??

in reply to Localhost network interaction in tests

I wrote a HTTP server module for testing HTTP clients. My advice is to just avoid the HTTP transfer and use file:// URIs to fetch a canned copy of a known good page from disk instead.

If you really, really want to embark on doing a full end-to-end test with a HTTP server that serves a canned copy of the modem pages, have a look at Test::HTTP::LocalServer, which provides a set of canned responses and can easily be extended to serve canned files as well. But still, it is far easier to substitute the base URI for accessing the modem to be a file:// URI instead.

Replies are listed 'Best First'.
Re^2: Localhost network interaction in tests
by fullermd (Priest) on Jan 02, 2012 at 00:32 UTC

    [...] Test::HTTP::LocalServer [...] substitute the base URI for accessing the modem to be a file:// URI instead.

    T:HTTP::LocalServer seems to pretty much mirror what I'm doing. With a bit less hardcoded single-purpose, anyway.

    I don't like the idea of going file:/// though, since that means I'd have to add an extra magic hook in the code to say "here, use this fake URL instead", which would defeat a lot of the purpose of running through the code path in the first place. It would still run the LWP bits, but the URL construction would be bypassed. Also doesn't give it the chance to double check that it properly errors on 404 as the test currently does either.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://945798]
LanX sigh ... pitty I'm not a girl ... missing out on so many things
LanX ... or is it "boying out" ?
[choroba]: RELEASE_TESTING=1 for Module::Starter based distributions
LanX ..."mistering out" ?
[talexb]: choroba AH! Thanks so much.
[choroba]: prove -bl xt in some others
[talexb]: OK, major issues with MANIFEST .. this'll take me a while.

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (10)
As of 2017-10-23 14:22 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (279 votes). Check out past polls.