Merge pull request #1112 from DeterminateSystems/project-jobset/search

Project jobset: update search
This commit is contained in:
Graham Christensen 2022-01-14 16:49:43 -05:00 committed by GitHub
commit 3a03784af6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 19 deletions

View file

@ -471,8 +471,10 @@ sub search :Local Args(0) {
, "jobset.hidden" => 0 , "jobset.hidden" => 0
, iscurrent => 1 , iscurrent => 1
}, },
{ order_by => ["project", "jobset", "job"], join => ["project", "jobset"] {
, rows => $c->stash->{limit} + 1 order_by => ["jobset.project", "jobset.name", "job"],
join => { "jobset" => "project" },
rows => $c->stash->{limit} + 1
} ) } )
]; ];

View file

@ -67,7 +67,7 @@
<tbody> <tbody>
[% FOREACH j IN jobs %] [% FOREACH j IN jobs %]
<tr> <tr>
<td><span>[% INCLUDE renderFullJobName project=j.get_column('project') jobset=j.get_column('jobset') job=j.job inRow=1 %]</span></td> <td><span>[% INCLUDE renderFullJobName project=j.jobset.get_column('project') jobset=j.jobset.get_column('name') job=j.job inRow=1 %]</span></td>
</tr> </tr>
[% END %] [% END %]
</tbody> </tbody>

View file

@ -2,26 +2,18 @@ use strict;
use warnings; use warnings;
use Setup; use Setup;
use Data::Dumper; use Data::Dumper;
use JSON::MaybeXS qw(decode_json);
my %ctx = test_init();
require Hydra::Schema;
require Hydra::Model::DB;
require Hydra::Helper::Nix;
use Test2::V0; use Test2::V0;
require Catalyst::Test; use JSON::MaybeXS qw(decode_json);
use Catalyst::Test ();
use HTTP::Request::Common; use HTTP::Request::Common;
my $ctx = test_context();
Catalyst::Test->import('Hydra'); Catalyst::Test->import('Hydra');
my $db = Hydra::Model::DB->new; my $builds = $ctx->makeAndEvaluateJobset(
hydra_setup($db); expression => "basic.nix"
);
my $project = $db->resultset('Projects')->create({name => "tests", displayname => "", owner => "root"});
my $jobset = createBaseJobset("basic", "basic.nix", $ctx{jobsdir});
ok(evalSucceeds($jobset), "Evaluating jobs/basic.nix should exit with return code 0");
subtest "/machines" => sub { subtest "/machines" => sub {
my $response = request(GET '/machines'); my $response = request(GET '/machines');
@ -50,6 +42,36 @@ subtest "/queue" => sub {
print STDERR Dumper $response->content; print STDERR Dumper $response->content;
} }
}; };
subtest "/search" => sub {
my $build = $builds->{"empty_dir"};
my ($build_output_out) = $build->buildoutputs->find({ name => "out" });
subtest "searching for projects" => sub {
my $response = request(GET "/search?query=${\$build->project->name}");
is($response->code, 200, "The search page 200's.");
};
subtest "searching for jobsets" => sub {
my $response = request(GET "/search?query=${\$build->jobset->name}");
is($response->code, 200, "The search page 200's.");
};
subtest "searching for jobs" => sub {
my $response = request(GET "/search?query=${\$build->job}");
is($response->code, 200, "The search page 200's.");
};
subtest "searching for output paths" => sub {
my $response = request(GET "/search?query=${\$build_output_out->path}");
is($response->code, 200, "The search page 200's.");
};
subtest "searching for derivation path" => sub {
my $response = request(GET "/search?query=${\$build->drvpath}");
is($response->code, 200, "The search page 200's.");
};
};
subtest "/status" => sub { subtest "/status" => sub {
my $response = request(GET '/status', Accept => 'application/json'); my $response = request(GET '/status', Accept => 'application/json');
ok($response->is_success, "The page showing the status 200's."); ok($response->is_success, "The page showing the status 200's.");