t/Controller/Build/constituents.t: assert the response is valid JSON, dump if it isn't

This commit is contained in:
Graham Christensen 2022-01-09 08:59:01 -05:00
parent 12ff981d24
commit 23d7046522

View file

@ -36,7 +36,14 @@ my $constituents = request(GET $url,
); );
ok($constituents->is_success, "Getting the constituent builds"); ok($constituents->is_success, "Getting the constituent builds");
my $data = decode_json($constituents->content);
my $data;
my $valid_json = lives { $data = decode_json($constituents->content); };
ok($valid_json, "We get back valid JSON.");
if (!$valid_json) {
use Data::Dumper;
print STDERR Dumper $constituents->content;
}
my ($buildA) = grep { $_->{nixname} eq "empty-dir-a" } @$data; my ($buildA) = grep { $_->{nixname} eq "empty-dir-a" } @$data;
my ($buildB) = grep { $_->{nixname} eq "empty-dir-b" } @$data; my ($buildB) = grep { $_->{nixname} eq "empty-dir-b" } @$data;