blob: 6508cfc79c9eef05da774ad7b26f9a713472b0e5 [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
Akron73f36082018-10-25 15:34:59 +02007my $mock_server = path(Mojo::File->new(__FILE__)->dirname, 'server')->child('mock.pl');
Akron0e1ed242018-10-11 13:22:00 +02008
Akron73f36082018-10-25 15:34:59 +02009my $t = Test::Mojo->new($mock_server);
Akron0e1ed242018-10-11 13:22:00 +020010
Akron63d963b2019-07-05 15:35:51 +020011$t->get_ok('/v1.0')
Akron0e1ed242018-10-11 13:22:00 +020012 ->status_is(200)
Akron6d49c1f2018-10-11 14:22:21 +020013 ->content_is('Fake server available');
Akron0e1ed242018-10-11 13:22:00 +020014
Akron63d963b2019-07-05 15:35:51 +020015$t->get_ok('/v1.0/search?ql=cosmas3')
Akron0e1ed242018-10-11 13:22:00 +020016 ->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
Akron63d963b2019-07-05 15:35:51 +020021$t->get_ok('/v1.0/search?q=server_fail')
Akron0e1ed242018-10-11 13:22:00 +020022 ->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
Akron63d963b2019-07-05 15:35:51 +020027$t->get_ok('/v1.0/search?q=[orth=das&ql=poliqarp&offset=0&count=25')
Akron0e1ed242018-10-11 13:22:00 +020028 ->status_is(400)
Akron8ea84292018-10-24 13:41:52 +020029 ->text_is('#error', '')
Akron0e1ed242018-10-11 13:22:00 +020030 ->json_is('/errors/0/0',302)
31 ->json_is('/errors/0/1','Parantheses/brackets unbalanced.')
32 ->json_is('/errors/1/0',302)
33 ->json_is('/errors/1/1','Could not parse query >>> [orth=das <<<.')
34 ;
35
Akron63d963b2019-07-05 15:35:51 +020036$t->get_ok('/v1.0/search?q=baum&ql=poliqarp&offset=0&count=25')
Akron32396632018-10-11 17:08:37 +020037 ->status_is(200)
Akron8ea84292018-10-24 13:41:52 +020038 ->text_is('#error', '')
Akron32396632018-10-11 17:08:37 +020039 ->json_is('/meta/count', 25)
40 ->json_is('/meta/serialQuery', "tokens:s:Baum")
41 ->json_is('/matches/0/docSigle', "GOE/AGI")
42 ;
43
Akron63d963b2019-07-05 15:35:51 +020044$t->get_ok('/v1.0/corpus/WPD15/232/39681/p2133-2134/matchInfo?spans=false&foundry=*')
Akronb80341d2018-10-15 19:46:23 +020045 ->status_is(200)
46 ->json_is('/textSigle', 'WPD15/232/39681')
47 ;
Akron32396632018-10-11 17:08:37 +020048
Akron0e1ed242018-10-11 13:22:00 +020049done_testing;
50__END__
Akron6d49c1f2018-10-11 14:22:21 +020051