[Http-webtest-commits] HTTP-WebTest/t 09-hooks.t,1.2,1.3
Brought to you by:
m_ilya,
richardanderson
From: Ilya M. <m_...@us...> - 2002-08-22 08:36:20
|
Update of /cvsroot/http-webtest/HTTP-WebTest/t In directory usw-pr-cvs1:/tmp/cvs-serv32146/t Modified Files: 09-hooks.t Log Message: Updated Index: 09-hooks.t =================================================================== RCS file: /cvsroot/http-webtest/HTTP-WebTest/t/09-hooks.t,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** 09-hooks.t 15 Feb 2002 15:42:20 -0000 1.2 --- 09-hooks.t 22 Aug 2002 08:36:13 -0000 1.3 *************** *** 19,23 **** use vars qw($HOSTNAME $PORT $URL $TEST); ! BEGIN { plan tests => 7 } # init tests --- 19,23 ---- use vars qw($HOSTNAME $PORT $URL $TEST); ! BEGIN { plan tests => 13 } # init tests *************** *** 57,61 **** my $tests1 = [ { url => abs_url($URL, '/inc_counter'), ! on_response => sub { $counter_value = counter(); [] } } ]; $WEBTEST->run_tests($tests1, $OPTS); --- 57,62 ---- my $tests1 = [ { url => abs_url($URL, '/inc_counter'), ! on_response => sub { $counter_value = counter(); [] } } ! ]; $WEBTEST->run_tests($tests1, $OPTS); *************** *** 72,76 **** } ! # 7: test response parameter which returns some test results { my $tests = [ { url => abs_url($URL, '/inc_counter'), --- 73,77 ---- } ! # 7: test on_response parameter returning some test results { my $tests = [ { url => abs_url($URL, '/inc_counter'), *************** *** 91,94 **** --- 92,147 ---- } + # 8-10: test on_start parameter + { + init_counter(); + + my $counter_value1 = undef; + my $counter_value2 = undef; + + my $opts = { %$OPTS, + on_start => sub { inc_counter() } }; + + my $tests1 = [ { url => abs_url($URL, '/inc_counter'), + on_request => sub { $counter_value1 = counter() } }, + { url => abs_url($URL, '/inc_counter'), + on_request => sub { $counter_value2 = counter() } } + ]; + + $WEBTEST->run_tests($tests1, $opts); + # this counter is set to one as it is increased by on_start hook + ok($counter_value1 == 1); + # this counter get ++ because it is increased by '/inc_counter' request + ok($counter_value2 == 2); + # this counter get ++ because it is increased by second + # '/inc_counter' request + ok(counter() == 3); + } + + # 11-13: test on_finish parameter + { + init_counter(); + + my $counter_value1 = undef; + my $counter_value2 = undef; + + my $opts = { %$OPTS, + on_finish => sub { inc_counter() } }; + + my $tests1 = [ { url => abs_url($URL, '/inc_counter'), + on_request => sub { $counter_value1 = counter() } }, + { url => abs_url($URL, '/inc_counter'), + on_request => sub { $counter_value2 = counter() } } + ]; + + $WEBTEST->run_tests($tests1, $opts); + # this counter is set to zero as no '/inc_counter' request and no + # hook that increase counter are run + ok($counter_value1 == 0); + # this counter get ++ because it is increased by '/inc_counter' request + ok($counter_value2 == 1); + # this counter get += 2 because it is increased by second + # '/inc_counter' request and by on_finish hook + ok(counter() == 3); + } # try to stop server even we have been crashed |