]> Dogcows Code - chaz/p5-HTTP-AnyUA/blob - t/14-delete.t
add Dockerfile for testing
[chaz/p5-HTTP-AnyUA] / t / 14-delete.t
1 #!perl
2
3 use warnings;
4 use strict;
5
6 use lib 't/lib';
7
8 use HTTP::AnyUA;
9 use Test::More;
10 use Util qw(:server :test :ua);
11
12 my $server = start_server('t/app.psgi');
13
14 plan tests => scalar user_agents;
15
16 test_all_user_agents {
17 plan tests => 8;
18
19 my $ua = shift;
20 my $any_ua = HTTP::AnyUA->new(ua => $ua, response_is_future => 1);
21
22 my $path = '/modify-document';
23 my $url = $server->url . $path;
24 my $future = $any_ua->delete($url);
25
26 $future->on_ready(sub {
27 my $self = shift;
28 my $resp = $self->is_done ? $self->get : $self->failure;
29 my $env = $server->read_env;
30
31 note explain 'RESPONSE: ', $resp;
32 note explain 'ENV: ', $env;
33
34 SKIP: {
35 skip 'unexpected env', 2 if ref($env) ne 'HASH';
36 is($env->{REQUEST_METHOD}, 'DELETE', 'correct method sent');
37 is($env->{REQUEST_URI}, $path, 'correct url sent');
38 }
39
40 is_response_reason($resp, 'No Content');
41 is_response_status($resp, 204);
42 is_response_success($resp, 1);
43 is_response_url($resp, $url);
44 response_protocol_ok($resp);
45
46 my $body = ref($resp) eq 'HASH' && $resp->{content};
47 ok(!$body, 'response body is empty');
48 });
49
50 return $future;
51 };
52
This page took 0.033048 seconds and 5 git commands to generate.