[Http-webtest-general] Re: last_test HTTP-WebTest-1.99_09
Brought to you by:
m_ilya,
richardanderson
From: Ilya M. <il...@ma...> - 2002-11-06 14:05:23
|
>>>>> On Tue, 5 Nov 2002 18:19:34 +0100, Kevin Baker <ke...@ri...> said: >> Anyway I've applied your patch and your code is in CVS >> repository. Thanks you again for the patch. KB> Looking into this a little further, I notice that KB> my patch may not be so well thought out. In that patch KB> I added the set last_test inside the loop (around line 130) KB> in HTTP::WebTest::API and removed the line at 133 that KB> was setting last_test to undef. I think now that KB> the it is not necessary to add the KB> $self->last_test($test); KB> inside the testing loop since I notice that it is set KB> in run_test at line 534. Well, your patch went into CVS only partially :) Sorry, I forgot to tell you. I've only removed that line and added test to asure that last_xxx methods work when tests are finished. KB> [..snip..] KB> I've got a workaround by using the on_response hooks. KB> I capture the location in the last test and set a var KB> that I use in the next test. KB> my $referral; KB> run_tests([ KB> { KB> url => 'mysite.com', KB> status_code => 302, KB> handle_redirects => 'no', KB> on_response => sub { KB> my $wt = shift; KB> $referral = $wt->last_response->headers->{'location'}; KB> []; KB> } KB> }, KB> { KB> url => sub { $referral }, KB> }, You could implement it without using on_response hook. Something like { url => sub { my $wt = shift; $wt->tests[$wt->last_test_num - 1]->response->headers->{'location'}; } } KB> The method names are a little confusing though (for me). KB> If I'm looking at the response in on_response I'd KB> expect the method to be called 'response'. 'last_response' KB> makes me think that it is referring to the last test's KB> response. ;-) I tend to agree with you. The thing is that these names are result of HTTP::WebTest code evolution. At the beginning these names made more sense. I probably will rename all last_xxx methods to current_xxx methods and add last_xxx methods that "do right thing". -- Ilya Martynov, il...@ip... CTO IPonWEB (UK) Ltd Quality Perl Programming and Unix Support UK managed @ offshore prices - http://www.iponweb.net Personal website - http://martynov.org |