This commit also add a test of this feature.
Note the search JSON output doesn't contain any jobs because they can not be exported to JSON yet.
The JSON output on a search query matching a build looks like:
{
"builds": [
{
"buildoutputs": {
"out": {
"path": "/nix/store/wdag3pznrvqk01byk989irg7rq3q2a2c-job"
}
},
"finished": 0,
"releasename": null,
"starttime": null,
"project": "sample",
"buildproducts": {},
"timestamp": 1541007629,
"buildstatus": null,
"nixname": "job",
"drvpath": "/nix/store/n9zqndn7j7nyr6gg3bmxvw26cfmdwv2n-job.drv",
"job": "job",
"id": 1,
"stoptime": null,
"priority": 100,
"system": "x86_64-linux",
"jobsetevals": [
1
],
"jobset": "default",
"buildmetrics": {}
}
],
"projects": [],
"jobsets": [],
"buildsdrv": []
}
MIMHJSZKFRNIKCYWQQDITZFPY6L2P43BSBPFERK3633CFDQY7YDAC
MMHOJIGD2SP24TV2TYGNLW7OUQ3ISSKRVCSWNDMXEKUXIJH247TAC
TX7Q4RASUYPTHIHZFACQ227BIZYLNJGRA5HHIAFQWCL4FHEHVGPQC
Q3VTDUSQ75JD5L55VWQV6MGAS6IC4AWGSADL2ISMX5E7R3LBVBHAC
FHOH54HQJOWN2HGIKLVADURVYYHIIORLKEFI4NVKE4K457GLG6CAC
J5UVLXOK6EDIL5I7VKWH4V2QDS4DPD7FHRK6XBWSXFRQS4JKXFZQC
LZVO64YG43JD7YMZSCTZNOBS5ROZA4FMPKJW2YOMHX2V5PTGBVWQC
my $search_project = decode_json(request_json({ uri => "/search/?query=sample" })->content());
ok($search_project->{projects}[0]->{name} == "sample", "Search for project 'sample' works");
my $search_build = decode_json(request_json({ uri => "/search/?query=" . $build->{buildoutputs}->{out}->{path} })->content());
ok($search_build->{builds}[0]->{buildoutputs}->{out}->{path} == $build->{buildoutputs}->{out}->{path}, "Search for builds work");