blob: ba795f7e444d664a1c895afc1629fdc4d4b9441b [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
Akron6d49c1f2018-10-11 14:22:21 +02009my $t = Test::Mojo->new($fixtures_path->child('fake_backend.pl'));
Akron0e1ed242018-10-11 13:22:00 +020010
11$t->get_ok('/')
12 ->status_is(200)
Akron6d49c1f2018-10-11 14:22:21 +020013 ->content_is('Fake server available');
Akron0e1ed242018-10-11 13:22:00 +020014
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)
Akron6d49c1f2018-10-11 14:22:21 +020023 ->text_is('#error', '')
Akron0e1ed242018-10-11 13:22:00 +020024 ->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
Akron32396632018-10-11 17:08:37 +020035$t->get_ok('/search?q=baum&ql=poliqarp')
36 ->status_is(200)
37 ->json_is('/meta/count', 25)
38 ->json_is('/meta/serialQuery', "tokens:s:Baum")
39 ->json_is('/matches/0/docSigle', "GOE/AGI")
40 ;
41
Akronb80341d2018-10-15 19:46:23 +020042$t->get_ok('/corpus/WPD15/232/39681/p2133-2134/matchInfo?spans=false&foundry=*')
43 ->status_is(200)
44 ->json_is('/textSigle', 'WPD15/232/39681')
45 ;
Akron32396632018-10-11 17:08:37 +020046
Akron0e1ed242018-10-11 13:22:00 +020047done_testing;
48__END__
Akron6d49c1f2018-10-11 14:22:21 +020049