Improve error handling
Change-Id: I1f54cf9cd4770d6602f70036cf0e27c9ede8c893
diff --git a/t/fixtures/fake_backend.pl b/t/fixtures/fake_backend.pl
index 89ad3c3..9f06697 100644
--- a/t/fixtures/fake_backend.pl
+++ b/t/fixtures/fake_backend.pl
@@ -36,6 +36,8 @@
my $c = shift;
my $q_name = shift;
my $file = $fixture_path->child("response_$q_name.json");
+ $c->app->log->debug("Load response from $file");
+
unless (-f $file) {
return {
status => 500,
@@ -44,6 +46,7 @@
}
}
};
+
my $response = $file->slurp;
return decode_json($response);
};
@@ -64,6 +67,8 @@
$v->optional('ql');
$v->optional('count');
$v->optional('context');
+ $v->optional('offset');
+ $v->optional('cutoff')->in(qw/true false/);
$c->app->log->debug('Receive request');
@@ -78,11 +83,16 @@
};
if (!$v->param('q')) {
- return $c->render(%{$c->load_response('no_query')});
+ return $c->render(%{$c->load_response('query_no_query')});
};
+ my @slug_base = ($v->param('q'));
+ push @slug_base, 'o' . $v->param('offset') if defined $v->param('offset');
+ push @slug_base, 'c' . $v->param('count') if defined $v->param('count');
+ push @slug_base, 'co' . $v->param('cutoff') if defined $v->param('cutoff');
+
# Get response based on query parameter
- my $response = $c->load_response(slugify($v->param('q')));
+ my $response = $c->load_response('query_' . slugify(join('_', @slug_base)));
# Check authentification
if (my $auth = $c->req->headers->header('Authorization')) {