blob: 15e4a87c4997e21be8b6512500dcaa36e5526298 [file] [log] [blame]
Akron0e1ed242018-10-11 13:22:00 +02001use Mojo::Base -strict;
2use Test::More;
3use Test::Mojo;
4use Mojo::File qw/path/;
5
6# Get the fixture path
7my $fixtures_path = path(Mojo::File->new(__FILE__)->dirname, 'fixtures');
8
9my $t = Test::Mojo->new($fixtures_path->child('query_backend.pl'));
10
11$t->get_ok('/')
12 ->status_is(200)
13 ->content_is('Query fake server available');
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)
23 ->content_like(qr!Oooops!)
24 ;
25
26$t->get_ok('/search?q=[orth=das&ql=poliqarp')
27 ->status_is(400)
28 ->json_is('/errors/0/0',302)
29 ->json_is('/errors/0/1','Parantheses/brackets unbalanced.')
30 ->json_is('/errors/1/0',302)
31 ->json_is('/errors/1/1','Could not parse query >>> [orth=das <<<.')
32 ;
33
34
35done_testing;
36__END__