From 04d8adaad337f26f64db5e31af708cad7c981036 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Thu, 24 Oct 2013 11:01:17 -0400 Subject: [PATCH] Cleanup Jobset serialization Signed-off-by: Shea Levy --- src/lib/Hydra/Schema/Jobsets.pm | 10 ++++++++++ tests/api-test.pl | 9 +++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/lib/Hydra/Schema/Jobsets.pm b/src/lib/Hydra/Schema/Jobsets.pm index 658e48ee..1c8e63f4 100644 --- a/src/lib/Hydra/Schema/Jobsets.pm +++ b/src/lib/Hydra/Schema/Jobsets.pm @@ -308,4 +308,14 @@ __PACKAGE__->has_many( # Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-10-14 15:46:29 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:DTAGxP5RFvcNxP/ciJGo4Q +my %hint = ( + relations => { + jobsetinputs => "name" + } +); + +sub json_hint { + return \%hint; +} + 1; diff --git a/tests/api-test.pl b/tests/api-test.pl index fa557669..e4128f29 100644 --- a/tests/api-test.pl +++ b/tests/api-test.pl @@ -1,6 +1,6 @@ use LWP::UserAgent; use JSON; -use Test::Simple tests => 7; +use Test::Simple tests => 9; #use Test::Simple tests => 15; my $ua = LWP::UserAgent->new; @@ -38,14 +38,15 @@ my $project = decode_json(request_json({ uri => '/project/sample' })->content()) ok((not @{$project->{jobsets}}), "A new project has no jobsets"); -=begin comment - $result = request_json({ uri => '/jobset/sample/default', method => 'PUT', data => { nixexprpath => "default.nix", nixexprinput => "my-src", inputs => { "my-src" => { type => "path", values => "/run/jobset" } }, enabled => "1", checkinterval => "3600"} }); ok($result->code() == 201, "PUTting a new jobset creates it"); my $jobset = decode_json(request_json({ uri => '/jobset/sample/default' })->content()); -ok($jobset->{jobsetinputs}->[0]->{name} eq "my-src", "The new jobset has a 'my-src' input"); +ok($jobset->{jobsetinputs}->[0] eq "my-src", "The new jobset has a 'my-src' input"); + +=begin comment + ok($jobset->{jobsetinputs}->[0]->{jobsetinputalts}->[0]->{value} eq "/run/jobset", "The 'my-src' input is in /run/jobset"); system("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");