File: external_lite_app.t

package info (click to toggle)
libmojolicious-perl 9.31%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,260 kB
  • sloc: perl: 10,139; makefile: 31; javascript: 1
file content (69 lines) | stat: -rw-r--r-- 1,717 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
use Mojo::Base -strict;

BEGIN {
  $ENV{MOJO_MODE}    = 'testing';
  $ENV{MOJO_REACTOR} = 'Mojo::Reactor::Poll';
}

use Test::More;

use Test::Mojo;
use Mojo::File qw(curfile);

my $t = Test::Mojo->new(curfile->sibling('external', 'myapp.pl'));

subtest 'Template from myapp.pl' => sub {
  $t->get_ok('/')->status_is(200)->content_is(<<'EOF');
myapp
works ♥!Insecure!Insecure!

too!works!!!Mojolicious::Plugin::Config::Sandbox
<a href="/">Test</a>
<form action="/%E2%98%83">
  <input type="submit" value="☃">
</form>
EOF
};

subtest 'Static file from myapp.pl' => sub {
  $t->get_ok('/index.html')->status_is(200)->content_is("External static file!\n");
};

subtest 'Echo from myapp.pl' => sub {
  $t->get_ok('/echo')->status_is(200)->content_is('echo: nothing!');
};

subtest 'Chunked response from myapp.pl' => sub {
  $t->get_ok('/stream')->status_is(200)->content_is('hello!');
};

subtest 'URL generated by myapp.pl' => sub {
  $t->get_ok('/url/☃')->status_is(200)->content_is('/url/%E2%98%83.json -> /%E2%98%83/stream!');
};

subtest 'Config value at startup time' => sub {
  $t->get_ok('/startup')->status_is(200)->content_is('Insecure!');
};

# Config override
$t = Test::Mojo->new(curfile->sibling('external', 'myapp.pl'),
  {one => 'override!', two => 'go!', just => 'yada', works => 'override two!'});

subtest 'Template from myapp.pl with config override' => sub {
  $t->get_ok('/')->status_is(200)->content_is(<<'EOF');
myapp
yadaoverride!go!

override two!*?
<a href="/">Test</a>
<form action="/%E2%98%83">
  <input type="submit" value="☃">
</form>
EOF
};

subtest 'Config override at startup time' => sub {
  $t->get_ok('/startup')->status_is(200)->content_is('override!');
};

done_testing();