Skip to content

Commit

Permalink
tests: hide backend error from tests not using backends
Browse files Browse the repository at this point in the history
  • Loading branch information
sni committed Jun 13, 2024
1 parent c1e0231 commit faabeca
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
12 changes: 10 additions & 2 deletions lib/Thruk/Controller/Root.pm
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ page: /thruk/changes.html
sub thruk_changes_html {
my( $c ) = @_;
$c->stash->{'hide_backends_chooser'} = 1;
Thruk::Action::AddDefaults::add_defaults($c, Thruk::Constants::ADD_SAFE_DEFAULTS);
# use cached and safe defaults
eval {
Thruk::Action::AddDefaults::add_defaults($c, [ Thruk::Constants::ADD_CACHED_DEFAULTS, Thruk::Constants::ADD_SAFE_DEFAULTS ]);
};
_debug("adding defaults failed: ".$@) if $@;
$c->stash->{infoBoxTitle} = 'Change Log';
$c->stash->{'title'} = 'Change Log';
$c->stash->{'no_auto_reload'} = 1;
Expand All @@ -141,7 +145,11 @@ page: /thruk/docs/
sub thruk_docs {
my( $c ) = @_;
$c->stash->{'hide_backends_chooser'} = 1;
Thruk::Action::AddDefaults::add_defaults($c, Thruk::Constants::ADD_SAFE_DEFAULTS);
# use cached and safe defaults
eval {
Thruk::Action::AddDefaults::add_defaults($c, [ Thruk::Constants::ADD_CACHED_DEFAULTS, Thruk::Constants::ADD_SAFE_DEFAULTS ]);
};
_debug("adding defaults failed: ".$@) if $@;
$c->stash->{infoBoxTitle} = 'Documentation';
$c->stash->{'title'} = 'Documentation';
$c->stash->{'no_auto_reload'} = 1;
Expand Down
4 changes: 3 additions & 1 deletion t/010-Thruk-Utils.t
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ ok(is_utf8($encoded), 'is_utf8 test20ac');

#########################
my $uri;
my($res, $context) = TestUtils::ctx_request('/thruk/main.html');
$c = $context;
$uri = Thruk::Utils::Filter::uri_with($c, {});
is($uri, 'main.html', 'uri_with without params');

Expand All @@ -255,7 +257,7 @@ is($uri, 'main.html?a=1&b=2&c=3', 'uri_with with 3 params');
$uri = Thruk::Utils::Filter::uri_with($c, { a => 1, b => undef, c => 'undef'});
is($uri, 'main.html?a=1', 'uri_with with undef params');

my($res, $context) = TestUtils::ctx_request('/thruk/main.html?a=1&b=2&c=3&a=4');
($res, $context) = TestUtils::ctx_request('/thruk/main.html?a=1&b=2&c=3&a=4');
$c = $context;

my $param_exp = {a=>[1,4], b => 2, c => 3};
Expand Down
2 changes: 1 addition & 1 deletion t/TestUtils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ sub get_c {
our($c);
return $c if defined $c;
my $res;
($res, $c) = ctx_request('/thruk/main.html');
($res, $c) = ctx_request('/thruk/changes.html');
return $c;
}

Expand Down

0 comments on commit faabeca

Please sign in to comment.