Skip to content

Commit

Permalink
Merge pull request #1684 from markogrady1/convert-proxy_app-to-use-su…
Browse files Browse the repository at this point in the history
…btests

convert t/mojolicious/proxy_app.t to use subtests
  • Loading branch information
mergify[bot] authored Feb 13, 2021
2 parents ba29ae1 + d63e278 commit dcb4a05
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions t/mojolicious/proxy_app.t
Original file line number Diff line number Diff line change
Expand Up @@ -101,23 +101,28 @@ get '/proxy3/:method/*target' => sub {

my $t = Test::Mojo->new;

# Various response variants
$t->get_ok('/proxy1/res1')->status_is(200)->header_is('X-Mojo-App' => 'One')->content_is('One!');
$t->get_ok('/proxy1/res2')->status_is(200)->header_is('X-Mojo-App' => 'Two')->content_is('Two!');
$t->get_ok('/proxy1/res3')->status_is(200)->header_is('X-Mojo-App' => 'Three')->header_is('X-Mojo-Method' => 'GET')
->header_is('X-Mojo-More' => '')->header_is('X-Mojo-Body' => 0)->content_is('Three!');
$t->get_ok('/proxy1/res4')->status_is(204)->header_is('X-Mojo-App' => 'Four')->content_is('');
$t->get_ok('/proxy1/res5')->status_is(400)->content_like(qr/Error: /);
$t->get_ok('/proxy1/res6')->status_is(200)->content_is('Six!');
subtest 'Various response variants' => sub {
$t->get_ok('/proxy1/res1')->status_is(200)->header_is('X-Mojo-App' => 'One')->content_is('One!');
$t->get_ok('/proxy1/res2')->status_is(200)->header_is('X-Mojo-App' => 'Two')->content_is('Two!');
$t->get_ok('/proxy1/res3')->status_is(200)->header_is('X-Mojo-App' => 'Three')->header_is('X-Mojo-Method' => 'GET')
->header_is('X-Mojo-More' => '')->header_is('X-Mojo-Body' => 0)->content_is('Three!');
$t->get_ok('/proxy1/res4')->status_is(204)->header_is('X-Mojo-App' => 'Four')->content_is('');
$t->get_ok('/proxy1/res5')->status_is(400)->content_like(qr/Error: /);
$t->get_ok('/proxy1/res6')->status_is(200)->content_is('Six!');
};

# Custom request
$t->patch_ok('/proxy2/res3')->status_is(200)->header_is('X-Mojo-App' => 'Three')->header_is('X-Mojo-Method' => 'POST')
->header_is('X-Mojo-More' => 'Less')->header_is('X-Mojo-Body' => 6)->content_is('Three!');
subtest 'Custom request' => sub {
$t->patch_ok('/proxy2/res3')->status_is(200)->header_is('X-Mojo-App' => 'Three')
->header_is('X-Mojo-Method' => 'POST')->header_is('X-Mojo-More' => 'Less')->header_is('X-Mojo-Body' => 6)
->content_is('Three!');
};

# Response modification
$t->get_ok('/proxy3/GET/res1')->status_is(200)->header_exists_not('X-Mojo-App')->header_is('X-Mojo-Proxy1' => 'just')
->header_is('X-Mojo-Proxy2' => 'works!')->content_is('One!');
$t->get_ok('/proxy3/POST/res3')->status_is(200)->header_is('X-Mojo-Method' => 'POST')->header_exists_not('X-Mojo-App')
->header_is('X-Mojo-Proxy1' => 'just')->header_is('X-Mojo-Proxy2' => 'works!')->content_is('Three!');
subtest 'Response modification' => sub {
$t->get_ok('/proxy3/GET/res1')->status_is(200)->header_exists_not('X-Mojo-App')->header_is('X-Mojo-Proxy1' => 'just')
->header_is('X-Mojo-Proxy2' => 'works!')->content_is('One!');
$t->get_ok('/proxy3/POST/res3')->status_is(200)->header_is('X-Mojo-Method' => 'POST')
->header_exists_not('X-Mojo-App')->header_is('X-Mojo-Proxy1' => 'just')->header_is('X-Mojo-Proxy2' => 'works!')
->content_is('Three!');
};

done_testing();

0 comments on commit dcb4a05

Please sign in to comment.