First working query example with promise based backend

Change-Id: Iee7360d123dc09876d942a32013077d78ea50b91
diff --git a/t/fixture.t b/t/fixture.t
index 3fd0bd3..6fac855 100644
--- a/t/fixture.t
+++ b/t/fixture.t
@@ -32,6 +32,14 @@
   ->json_is('/errors/1/1','Could not parse query >>> [orth=das <<<.')
   ;
 
+$t->get_ok('/search?q=baum&ql=poliqarp')
+  ->status_is(200)
+  ->json_is('/meta/count', 25)
+  ->json_is('/meta/serialQuery', "tokens:s:Baum")
+  ->json_is('/matches/0/docSigle', "GOE/AGI")
+  ;
+
+
 done_testing;
 __END__
 
diff --git a/t/fixtures/fake_backend.pl b/t/fixtures/fake_backend.pl
index 73b4561..e7fc518 100644
--- a/t/fixtures/fake_backend.pl
+++ b/t/fixtures/fake_backend.pl
@@ -54,6 +54,7 @@
   shift->render(text => 'Fake server available');
 };
 
+
 # Search fixtures
 get '/search' => sub {
   my $c = shift;
@@ -64,6 +65,8 @@
   $v->optional('count');
   $v->optional('context');
 
+  $c->app->log->debug('Receive request');
+
   # Response q=x&ql=cosmas3
   if ($v->param('ql') && $v->param('ql') eq 'cosmas3') {
     return $c->render(
@@ -93,9 +96,12 @@
     $response->{json}->{meta}->{startIndex} = $v->param("startIndex");
   };
 
-
   # Simple search fixture
-  return $c->render(%$response);
+  $c->render(%$response);
+
+  $c->app->log->debug('Rendered result');
+
+  return 1;
 };
 
 
diff --git a/t/query.t b/t/query.t
index de05a78..75ed9b8 100644
--- a/t/query.t
+++ b/t/query.t
@@ -1,16 +1,37 @@
 use Mojo::Base -strict;
 use Test::Mojo;
 use Test::More;
+use Mojo::File qw/path/;
+
+
+#####################
+# Start Fake server #
+#####################
+my $mount_point = '/api/';
+$ENV{KALAMAR_API} = $mount_point;
 
 my $t = Test::Mojo->new('Kalamar');
 
+# Mount fake backend
+# Get the fixture path
+my $fixtures_path = path(Mojo::File->new(__FILE__)->dirname, 'fixtures');
+my $fake_backend = $t->app->plugin(
+  Mount => {
+    $mount_point =>
+      $fixtures_path->child('fake_backend.pl')
+  }
+);
+# Configure fake backend
+$fake_backend->pattern->defaults->{app}->log($t->app->log);
+
 # Query passed
-$t->get_ok('/q2?q=hui')
+$t->get_ok('/q2?q=baum')
   ->status_is(200)
   ->text_is('#error','')
-  ->text_is('title', 'KorAP: Find »hui« with Poliqarp')
-  ->element_exists('meta[name="DC.title"][content="KorAP: Find »hui« with Poliqarp"]')
+  ->text_is('title', 'KorAP: Find »baum« with Poliqarp')
+  ->element_exists('meta[name="DC.title"][content="KorAP: Find »baum« with Poliqarp"]')
   ->element_exists('body[itemscope][itemtype="http://schema.org/SearchResultsPage"]')
+  ->text_is('#total-results', 51)
   ;
 
 
diff --git a/t/remote_user.t b/t/remote_user.t
index 96897e5..ee0b872 100644
--- a/t/remote_user.t
+++ b/t/remote_user.t
@@ -4,6 +4,10 @@
 use Mojo::File qw/path/;
 use Data::Dumper;
 
+
+#####################
+# Start Fake server #
+#####################
 my $mount_point = '/api/';
 $ENV{KALAMAR_API} = $mount_point;
 
@@ -19,10 +23,10 @@
       $fixtures_path->child('fake_backend.pl')
   }
 );
-
 # Configure fake backend
 $fake_backend->pattern->defaults->{app}->log($t->app->log);
 
+
 $t->get_ok('/api')
   ->status_is(200)
   ->content_is('Fake server available');
@@ -58,6 +62,7 @@
   ->tx->res->dom->at('input[name=csrf_token]')->attr('value')
   ;
 
+
 $t->post_ok('/user/login' => form => { handle_or_email => 'test', pwd => 'pass', csrf_token => $csrf })
   ->status_is(302)
   ->header_is('Location' => '/');