Akron | 0e1ed24 | 2018-10-11 13:22:00 +0200 | [diff] [blame] | 1 | use Mojo::Base -strict; |
| 2 | use Test::More; |
| 3 | use Test::Mojo; |
| 4 | use Mojo::File qw/path/; |
| 5 | |
| 6 | # Get the fixture path |
| 7 | my $fixtures_path = path(Mojo::File->new(__FILE__)->dirname, 'fixtures'); |
| 8 | |
Akron | 6d49c1f | 2018-10-11 14:22:21 +0200 | [diff] [blame] | 9 | my $t = Test::Mojo->new($fixtures_path->child('fake_backend.pl')); |
Akron | 0e1ed24 | 2018-10-11 13:22:00 +0200 | [diff] [blame] | 10 | |
| 11 | $t->get_ok('/') |
| 12 | ->status_is(200) |
Akron | 6d49c1f | 2018-10-11 14:22:21 +0200 | [diff] [blame] | 13 | ->content_is('Fake server available'); |
Akron | 0e1ed24 | 2018-10-11 13:22:00 +0200 | [diff] [blame] | 14 | |
| 15 | $t->get_ok('/search?ql=cosmas3') |
| 16 | ->status_is(400) |
| 17 | ->json_is('/errors/0/0',"307") |
| 18 | ->json_is('/errors/0/1',"cosmas3 is not a supported query language!") |
| 19 | ; |
| 20 | |
| 21 | $t->get_ok('/search?q=server_fail') |
| 22 | ->status_is(500) |
Akron | 6d49c1f | 2018-10-11 14:22:21 +0200 | [diff] [blame] | 23 | ->text_is('#error', '') |
Akron | 0e1ed24 | 2018-10-11 13:22:00 +0200 | [diff] [blame] | 24 | ->content_like(qr!Oooops!) |
| 25 | ; |
| 26 | |
| 27 | $t->get_ok('/search?q=[orth=das&ql=poliqarp') |
| 28 | ->status_is(400) |
| 29 | ->json_is('/errors/0/0',302) |
| 30 | ->json_is('/errors/0/1','Parantheses/brackets unbalanced.') |
| 31 | ->json_is('/errors/1/0',302) |
| 32 | ->json_is('/errors/1/1','Could not parse query >>> [orth=das <<<.') |
| 33 | ; |
| 34 | |
Akron | 0e1ed24 | 2018-10-11 13:22:00 +0200 | [diff] [blame] | 35 | done_testing; |
| 36 | __END__ |
Akron | 6d49c1f | 2018-10-11 14:22:21 +0200 | [diff] [blame] | 37 | |