Changeset 17317

Show
Ignore:
Timestamp:
08/10/08 10:26:44 (5 years ago)
Author:
tokuhirom
Message:

added new test utility(run_engine).

Location:
lang/perl/HTTP-Engine/trunk/t
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/HTTP-Engine/trunk/t/010_core/request-cookie.t

    r17316 r17317  
    22use warnings; 
    33use Test::More tests => 4; 
     4use t::Utils; 
    45use HTTP::Engine; 
    56use HTTP::Request; 
    67use CGI::Simple::Cookie; 
    7  
    8 sub _test { 
    9     my ($req, $cb) = @_; 
    10  
    11     HTTP::Engine->new( 
    12         interface => { 
    13             module => 'Test', 
    14             args => { }, 
    15             request_handler => $cb, 
    16         }, 
    17     )->run($req); 
    18 } 
    198 
    209# exist Cookie header. 
     
    3019 
    3120    # do test 
    32     _test($req, sub { 
     21    run_engine($req, sub { 
    3322        my $c = shift; 
    3423        is $c->req->cookie('Foo')->value, 'Bar'; 
     
    4736 
    4837    # do test 
    49     _test($req, sub { 
     38    run_engine($req, sub { 
    5039        my $c = shift; 
    5140        is_deeply $c->req->cookies, {}; 
  • lang/perl/HTTP-Engine/trunk/t/Utils.pm

    r17298 r17317  
    33use strict; 
    44use warnings; 
     5use HTTP::Engine; 
    56 
    67use IO::Socket::INET; 
    78 
    89use Sub::Exporter -setup => { 
    9     exports => [qw/ empty_port daemonize daemonize_all interfaces /], 
     10    exports => [qw/ empty_port daemonize daemonize_all interfaces run_engine /], 
    1011    groups  => { default => [':all'] } 
    1112}; 
     
    7172} 
    7273 
     74sub run_engine { 
     75    my ($req, $cb) = @_; 
     76 
     77    HTTP::Engine->new( 
     78        interface => { 
     79            module => 'Test', 
     80            args => { }, 
     81            request_handler => $cb, 
     82        }, 
     83    )->run($req); 
     84} 
     85 
    73861;