@@ -102,4 +102,48 @@ 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+ my $buildstep_length = @buildsteplist ;
127+
128+ # Create the expected output with the build step information in it.
129+ my $expected = {
130+ project => " tests" ,
131+ jobset => " aggregate" ,
132+ outPath => $aggregateBuild -> buildoutputs-> find({ name => " out" })-> path,
133+ buildstatus => 0,
134+ drvPath => $aggregateBuild -> drvpath,
135+ buildId => $aggregateBuild -> id,
136+ priority => undef ,
137+ finished => 1,
138+ id => $aggregateBuild -> id,
139+ job => " aggregate" ,
140+ nixname => " aggregate" ,
141+ timestamp => $aggregateBuild -> timestamp,
142+ system => $aggregateBuild -> system ,
143+ steps => \@buildsteplist ,
144+ };
145+
146+ is($data , $expected , " The build's info JSON matches our API." );
147+ };
148+
105149done_testing;
0 commit comments