<commit_before>use v6.c;

use Test;

use Bailador::Test;

plan 12;

%*ENV<P6W_CONTAINER> = 'Bailador::Test';
my $app = EVALFILE "examples/app.pl6";

subtest {
    plan 3;
    my %data = run-psgi-request($app, 'GET', '/');
    my $html = %data<response>[2];
    %data<response>[2] = '';
    is-deeply %data<response>, [200, ["Content-Type" => "text/html"], ''], 'route GET /';
    is %data<err>, '';
    like $html, rx:s/\<h2\>Welcome to Bailador\!\<\/h2\>/;
}, '/';


subtest {
    plan 2;
    my %data = run-psgi-request($app, 'GET', '/red');
    is-deeply %data<response>, [302, ["Content-Type" => "text/html", :Location("/index.html")], "Not found"], 'route GET /red';
    is %data<err>, '';
}, '/red';

subtest {
    plan 3;
    my %data = run-psgi-request($app, 'GET', '/die');
    is %data<response>[0], 500;
    is-deeply %data<response>[1], ["Content-Type" => "text/html;charset=UTF-8"];
    like %data<err>, rx:s/This is an exception so you can see how it is handled/, 'stderr';
}, '/die';

subtest {
    plan 2;
    my %data = run-psgi-request($app, 'GET', '/about');
    is-deeply %data<response>, [200, ["Content-Type" => "text/html"], 'about me'], 'route GET /about';
    is %data<err>, '';
}, '/about';

subtest {
    plan 2;
    my %data = run-psgi-request($app, 'GET', '/hello/Foo');
    is-deeply %data<response>, [200, ["Content-Type" => "text/html"], 'Hello Foo!'], 'route GET /hello/Foo';
    is %data<err>, '';
}, '/hello/Foo';

todo "See https://github.com/Bailador/Bailador/issues/178";
subtest {
    plan 2;
    my %data = run-psgi-request($app, 'GET', '/hello/Foo.html');
    is-deeply %data<response>, [200, ["Content-Type" => "text/html"], 'Hello Foo.html!'], 'route GET /hello/Foo.html';
    is %data<err>, '';
}, '/hello/foo.html';


subtest {
    plan 2;
    my %data = run-psgi-request($app, 'GET', '/abc');
    is-deeply %data<response>, [404, ["Content-Type" => "text/html;charset=UTF-8"], 'Not found'], 'route GET /abc';
    is %data<err>, '';
}, '/abc';

todo 'See https://github.com/Bailador/Bailador/issues/177';
subtest {
    plan 2;
    my %data = run-psgi-request($app, 'GET', '/hello/Foo/Bar');
    is-deeply %data<response>, [404, ["Content-Type" => "text/html;charset=UTF-8"], 'Not found'], 'route GET /hello/Foo/Bar';
    is %data<err>, '';
}, '/hello/Foo/Bar';

subtest {
    plan 2;
    my %data = run-psgi-request($app, 'GET', '/def/egy/ketto');
    is-deeply %data<response>, [200, ["Content-Type" => "text/html"], q{Hello 'egy' and 'ketto'!}], 'route GET /def/egy/ketto';
    is %data<err>, '';<commit_msg>enable test to verify #177<commit_after>use v6.c;

use Test;

use Bailador::Test;

plan 12;

%*ENV<P6W_CONTAINER> = 'Bailador::Test';
my $app = EVALFILE "examples/app.pl6";

subtest {
    plan 3;
    my %data = run-psgi-request($app, 'GET', '/');
    my $html = %data<response>[2];
    %data<response>[2] = '';
    is-deeply %data<response>, [200, ["Content-Type" => "text/html"], ''], 'route GET /';
    is %data<err>, '';
    like $html, rx:s/\<h2\>Welcome to Bailador\!\<\/h2\>/;
}, '/';


subtest {
    plan 2;
    my %data = run-psgi-request($app, 'GET', '/red');
    is-deeply %data<response>, [302, ["Content-Type" => "text/html", :Location("/index.html")], "Not found"], 'route GET /red';
    is %data<err>, '';
}, '/red';

subtest {
    plan 3;
    my %data = run-psgi-request($app, 'GET', '/die');
    is %data<response>[0], 500;
    is-deeply %data<response>[1], ["Content-Type" => "text/html;charset=UTF-8"];
    like %data<err>, rx:s/This is an exception so you can see how it is handled/, 'stderr';
}, '/die';

subtest {
    plan 2;
    my %data = run-psgi-request($app, 'GET', '/about');
    is-deeply %data<response>, [200, ["Content-Type" => "text/html"], 'about me'], 'route GET /about';
    is %data<err>, '';
}, '/about';

subtest {
    plan 2;
    my %data = run-psgi-request($app, 'GET', '/hello/Foo');
    is-deeply %data<response>, [200, ["Content-Type" => "text/html"], 'Hello Foo!'], 'route GET /hello/Foo';
    is %data<err>, '';
}, '/hello/Foo';

todo "See https://github.com/Bailador/Bailador/issues/178";
subtest {
    plan 2;
    my %data = run-psgi-request($app, 'GET', '/hello/Foo.html');
    is-deeply %data<response>, [200, ["Content-Type" => "text/html"], 'Hello Foo.html!'], 'route GET /hello/Foo.html';
    is %data<err>, '';
}, '/hello/foo.html';


subtest {
    plan 2;
    my %data = run-psgi-request($app, 'GET', '/abc');
    is-deeply %data<response>, [404, ["Content-Type" => "text/html;charset=UTF-8"], 'Not found'], 'route GET /abc';
    is %data<err>, '';
}, '/abc';

#todo 'See https://github.com/Bailador/Bailador/issues/177';
subtest {
    plan 2;
    my %data = run-psgi-request($app, 'GET', '/hello/Foo/Bar');
    is-deeply %data<response>, [404, ["Content-Type" => "text/html;charset=UTF-8"], 'Not found'], 'route GET /hello/Foo/Bar';
    is %data<err>, '';
}, '/hello/Foo/Bar';

subtest {
    plan 2;
    my %data = run-psgi-request($app, 'GET', '/def/egy/ketto');
    is-deeply %data<response>, [200, ["Content-Type" => "text/html"], q{Hello 'egy' and 'ketto'!}], 'route GET /def/egy/ketto';
    is %data<err>, '';
{'fraction_non_alphanumeric': 0.2459016393442623, 'fraction_numerical': 0.022443403590944575, 'mean_word_length': 3.4449262792714657, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 69, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '767073', 'n_tokens_mistral': 2081, 'n_tokens_neox': 1966, 'n_words': 454}