]> iEval git - gruntmaster-data.git/blame - t/Gruntmaster-Opener.t
Do not crash in t/tools.t if postgres is not running
[gruntmaster-data.git] / t / Gruntmaster-Opener.t
CommitLineData
a832cd59
MG
1#!/usr/bin/perl
2use v5.14;
3use warnings;
4
5use Test::More tests => 8;
6use Gruntmaster::Opener;
7
8my $opened;
9BEGIN {
10 no warnings 'redefine';
11 *Gruntmaster::Opener::open_problem = sub { $opened = 1 };
12}
13
14sub _test {
15 my ($line, $should_open, $name) = @_;
16 $line =~ s,DATE,[01/Jan/2015:00:00:00 +0200],;
17 $opened = '';
18 handle_line $line;
19 is $opened, $should_open, $name
20}
21
22_test '192.0.2.41 - mgv DATE "GET /pb/problem1?contest=test HTTP/1.1" 200 1234', 1, 'normal case';
23_test '192.0.2.41 - mgv DATE "HEAD http://gruntmaster.example.org/pb/problem1?contest=test HTTP/1.0" 200 1234', 1, 'absolute url';
24_test '2001:db8:abcd::1234 - mgv DATE "GET /pb/%61%62%63%64?%63ontes%74=%62%61%64 SPDY/3" 200 1234', 1, 'superfluous percent encoding';
25
26_test '192.0.2.41 - mgv DATE "GET /pb/problem1?contest=test HTTP/1.1" 500 1234', '', 'internal server error';
27_test '192.0.2.41 - - DATE "GET /pb/problem1?contest=test HTTP/1.1" 401 1234', '', 'not logged in';
28_test '192.0.2.41 - mgv DATE "GET /pb/?contest=test HTTP/1.0" 200 1234', '', 'problem list';
29_test '2001:db8:abcd::1234 - mgv DATE "GET /pb/asd SPDY/3" 200 1234', '', 'not in contest';
30_test 'junk', '', 'junk';
This page took 0.024959 seconds and 4 git commands to generate.