@@ -102,4 +102,47 @@ subtest "accessing the constituents API" => sub {
102102 is($buildB -> {job }, " b" );
103103};
104104
105+ subtest " accessing the get-info API" => sub {
106+ my $url = $build_url . " /api/get-info" ;
107+
108+ my $build_info = request(GET $url ,
109+ Accept => ' application/json' ,
110+ );
111+
112+ ok($build_info -> is_success, " Getting the build info" );
113+
114+ my $data ;
115+ my $valid_json = lives { $data = decode_json($build_info -> content); };
116+ ok($valid_json , " We get back valid JSON." );
117+ if (!$valid_json ) {
118+ use Data::Dumper;
119+ print STDERR Dumper $build_info -> content;
120+ }
121+
122+ # Query the build steps from the aggregate build and create the expected list of results.
123+ my @buildsteps = $aggregateBuild -> buildsteps-> search({}, {order_by => " stepnr asc" });
124+ my @buildsteplist ;
125+ push @buildsteplist , Hydra::Controller::Build::buildStepToHash($_ ) foreach @buildsteps ;
126+
127+ # Create the expected output with the build step information in it.
128+ my $expected = {
129+ project => " tests" ,
130+ jobset => " aggregate" ,
131+ outPath => $aggregateBuild -> buildoutputs-> find({ name => " out" })-> path,
132+ buildstatus => 0,
133+ drvPath => $aggregateBuild -> drvpath,
134+ buildId => $aggregateBuild -> id,
135+ priority => undef ,
136+ finished => 1,
137+ id => $aggregateBuild -> id,
138+ job => " aggregate" ,
139+ nixname => " aggregate" ,
140+ timestamp => $aggregateBuild -> timestamp,
141+ system => $aggregateBuild -> system ,
142+ steps => \@buildsteplist ,
143+ };
144+
145+ is($data , $expected , " The build's info JSON matches our API." );
146+ };
147+
105148done_testing;
0 commit comments