X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fpost.t;h=09818581b545f029c615dbf70451d6f04a99c0dc;hb=82340c7806521a32bba9b239e82bde21c09a43a5;hp=c90825605fe84524d4895619fd7f46272f065365;hpb=05aafc1a964aa5c2e86690602d5c49a8329fb90c;p=catagits%2FWeb-Simple.git diff --git a/t/post.t b/t/post.t index c908256..0981858 100644 --- a/t/post.t +++ b/t/post.t @@ -23,38 +23,31 @@ use Test::More qw(no_plan); } } -use Plack::Test; use HTTP::Request::Common qw(GET POST); my $app = PostTest->new; +sub run_request { $app->run_test_request(@_); } -sub run_request { - my $request = shift; - my $response; - test_psgi($app->to_psgi_app, sub { $response = shift->($request) }); - return $response; -} - -my $get = run_request(GET 'http://localhost/'); +my $get = run_request(GET => 'http://localhost/'); cmp_ok($get->code, '==', 404, '404 on GET'); -my $no_body = run_request(POST 'http://localhost/'); +my $no_body = run_request(POST => 'http://localhost/'); cmp_ok($no_body->code, '==', 404, '404 with empty body'); -my $no_foo = run_request(POST 'http://localhost/' => [ bar => 'BAR' ]); +my $no_foo = run_request(POST => 'http://localhost/' => [ bar => 'BAR' ]); cmp_ok($no_foo->code, '==', 404, '404 with no foo param'); -my $no_bar = run_request(POST 'http://localhost/' => [ foo => 'FOO' ]); +my $no_bar = run_request(POST => 'http://localhost/' => [ foo => 'FOO' ]); cmp_ok($no_bar->code, '==', 200, '200 with only foo param'); is($no_bar->content, 'FOO EMPTY', 'bar defaulted'); my $both = run_request( - POST 'http://localhost/' => [ foo => 'FOO', bar => 'BAR' ] + POST => 'http://localhost/' => [ foo => 'FOO', bar => 'BAR' ] ); cmp_ok($both->code, '==', 200, '200 with both params'); @@ -75,7 +68,7 @@ cmp_ok($upload->code, '==', 200, '200 with multipart'); is($upload->content, 'FOO BAR', 'both params returned'); my $upload_wrongtype = run_request( - POST 'http://localhost' + POST => 'http://localhost' => [ baz => 'fleem' ] );