Skip to content

Commit

Permalink
Flesh out the API a bit
Browse files Browse the repository at this point in the history
Signed-off-by: Shea Levy <shea@shealevy.com>
  • Loading branch information
shlevy committed Oct 29, 2013
1 parent b51b8cd commit 4eef090
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/lib/Hydra/Controller/Jobset.pm
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ sub evals_GET {
my $offset = ($page - 1) * $resultsPerPage;
$c->stash->{evals} = getEvals($self, $c, $evals, $offset, $resultsPerPage);
my %entity = (
evals => $c->stash->{evals},
evals => [ map { $_->{eval} } @{$c->stash->{evals}} ],
first => "?page=1",
last => "?page=" . POSIX::ceil($c->stash->{total}/$resultsPerPage)
);
Expand Down
1 change: 1 addition & 0 deletions src/lib/Hydra/Schema/Builds.pm
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ my %hint = (
'id',
'finished',
'timestamp',
'starttime',
'stoptime',
'project',
'jobset',
Expand Down
4 changes: 3 additions & 1 deletion src/lib/Hydra/Schema/JobsetEvalInputs.pm
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ __PACKAGE__->belongs_to(

my %hint = (
columns => [
"revision"
"revision",
"type",
"uri"
],
);

Expand Down
6 changes: 6 additions & 0 deletions src/lib/Hydra/Schema/Jobsets.pm
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,12 @@ __PACKAGE__->has_many(
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:DTAGxP5RFvcNxP/ciJGo4Q

my %hint = (
columns => [
"enabled",
"errormsg",
"fetcherrormsg",
"emailoverride"
],
eager_relations => {
jobsetinputs => "name"
}
Expand Down
6 changes: 3 additions & 3 deletions tests/api-test.pl
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ sub request_json {
ok($result->code() == 200, "Can get evals of a jobset");
my $evals = decode_json($result->content())->{evals};
my $eval = $evals->[0];
ok($eval->{eval}->{hasnewbuilds} == 1, "The first eval of a jobset has new builds");
ok($eval->{hasnewbuilds} == 1, "The first eval of a jobset has new builds");

# Ugh, cached for 30s
sleep 30;
system("echo >> /run/jobset/default.nix; LOGNAME=root NIX_STORE_DIR=/run/nix/store NIX_LOG_DIR=/run/nix/var/log/nix NIX_STATE_DIR=/run/nix/var/nix HYDRA_DATA=/var/lib/hydra HYDRA_DBI='dbi:Pg:dbname=hydra;user=root;' hydra-evaluator sample default");
my $evals = decode_json(request_json({ uri => '/jobset/sample/default/evals' })->content())->{evals};
ok($evals->[0]->{eval}->{jobsetevalinputs}->{"my-src"}->{revision} != $evals->[1]->{eval}->{jobsetevalinputs}->{"my-src"}->{revision}, "Changing a jobset source changes its revision");
ok($evals->[0]->{jobsetevalinputs}->{"my-src"}->{revision} != $evals->[1]->{jobsetevalinputs}->{"my-src"}->{revision}, "Changing a jobset source changes its revision");

my $build = decode_json(request_json({ uri => "/build/" . $evals->[0]->{eval}->{builds}->[0] })->content());
my $build = decode_json(request_json({ uri => "/build/" . $evals->[0]->{builds}->[0] })->content());
ok($build->{job} eq "job", "The build's job name is job");
ok($build->{finished} == 0, "The build isn't finished yet");

0 comments on commit 4eef090

Please sign in to comment.