File: before.t

package info (click to toggle)
libmojolicious-plugin-cgi-perl 0.36-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 208 kB
  • ctags: 17
  • sloc: perl: 300; makefile: 2
file content (20 lines) | stat: -rw-r--r-- 528 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use t::Helper;

use Mojolicious::Lite;
plugin CGI => {
  route  => '/user/:id',
  script => cgi_script('env.cgi'),
  before => sub {
    my $c     = shift;
    my $query = $c->req->url->query;

    $query->param(id          => $c->stash('id'));
    $query->param(other_value => 123);
  },
};

Test::Mojo->new->get_ok('/user/42')->status_is(200)
  ->content_like(qr{^QUERY_STRING=id=42}m,             'QUERY_STRING=id=42')
  ->content_like(qr{^QUERY_STRING=.*other_value=123}m, 'QUERY_STRING=...other_value=123');

done_testing;