diff options
author | franck cuny <franck@lumberjaph.net> | 2010-11-24 12:01:02 +0100 |
---|---|---|
committer | franck cuny <franck@lumberjaph.net> | 2010-11-24 12:01:02 +0100 |
commit | e53d74d8cdc793874f432748e1ccedc5ab3144e4 (patch) | |
tree | f721ddf142f053acf899475d1bdd7ce3f1bb6375 | |
parent | stringify body to a usefull message (diff) | |
download | net-http-spore-e53d74d8cdc793874f432748e1ccedc5ab3144e4.tar.gz |
update tests
-rw-r--r-- | t/spore-middleware/auth-basic.t | 11 | ||||
-rw-r--r-- | t/spore-request/exception.t | 17 |
2 files changed, 21 insertions, 7 deletions
diff --git a/t/spore-middleware/auth-basic.t b/t/spore-middleware/auth-basic.t index a6c5ac7..cc5ee3e 100644 --- a/t/spore-middleware/auth-basic.t +++ b/t/spore-middleware/auth-basic.t @@ -4,6 +4,7 @@ use warnings; use Test::More; use MIME::Base64; +use Try::Tiny; use Net::HTTP::Spore; my $username = 'franck'; @@ -44,11 +45,15 @@ foreach my $test (@tests) { 't/specs/api.json', base_url => 'http://localhost/' ), 'client created'; + foreach ( @{ $test->{middlewares} } ) { $client->enable(@$_); } - my $res = $client->get_info(); - is $res->[0], $test->{expected}->{status}, 'valid HTTP status'; - is $res->[2], $test->{expected}->{body}, 'valid HTTP body'; + my $res; + + try { $res = $client->get_info(); } catch { $res = $_ }; + + is $res->status, $test->{expected}->{status}, 'valid HTTP status'; + is $res->body, $test->{expected}->{body}, 'valid HTTP body'; } diff --git a/t/spore-request/exception.t b/t/spore-request/exception.t index fdf51cb..1173e84 100644 --- a/t/spore-request/exception.t +++ b/t/spore-request/exception.t @@ -1,6 +1,7 @@ use strict; use warnings; +use Try::Tiny; use Test::More; use Net::HTTP::Spore; @@ -13,12 +14,20 @@ my $mock_server = { ok my $client = Net::HTTP::Spore->new_from_spec( 't/specs/api.json', - base_url => 'http://localhost' ); + base_url => 'http://localhost' ), "client created"; $client->enable( 'Mock', tests => $mock_server ); -my $res = $client->get_info(); -is $res->[0], 599; -like $res->[2]->{error}, qr/Died/; +my $res; + +try { + $res = $client->get_info(); +} +catch { + $res = $_; + like $res, qr/status: 599/, "stringify ok"; + is $res->[0], 599, "status ok (as arrayref)"; + like $res->[2]->{error}, qr/Died/, "body ok (as arrayref)"; +}; done_testing; |