Relocate new tests in to the Hydra subdir

This commit is contained in:
Graham Christensen
2022-01-11 09:54:51 -05:00
parent b41818e067
commit ca6ba409de
2 changed files with 0 additions and 0 deletions

View File

@ -0,0 +1,28 @@
use feature 'unicode_strings';
use strict;
use warnings;
use Setup;
use JSON::MaybeXS qw(decode_json encode_json);
my %ctx = test_init();
require Hydra::Schema;
require Hydra::Model::DB;
require Hydra::Helper::Nix;
use Test2::V0;
require Catalyst::Test;
Catalyst::Test->import('Hydra');
use HTTP::Request::Common qw(POST PUT GET DELETE);
my $db = Hydra::Model::DB->new;
hydra_setup($db);
my $jobset = createBaseJobset("basic", "basic.nix", $ctx{jobsdir});
ok(evalSucceeds($jobset), "Evaluating jobs/basic.nix should exit with return code 0");
my ($eval, @evals) = $jobset->jobsetevals;
my $fetch = request(GET '/eval/' . $eval->id);
is($fetch->code, 200, "eval page is 200");
done_testing;

106
t/Hydra/Helper/BuildDiff.t Normal file
View File

@ -0,0 +1,106 @@
use strict;
use warnings;
use Setup;
use Test2::V0;
use Hydra::Helper::BuildDiff;
my $ctx = test_context();
my $builds = $ctx->makeAndEvaluateJobset(
expression => "basic.nix",
build => 1
);
subtest "empty diff" => sub {
my $ret = buildDiff([], []);
is(
$ret,
{
stillSucceed => [],
stillFail => [],
nowSucceed => [],
nowFail => [],
new => [],
removed => [],
unfinished => [],
aborted => [],
failed => [],
},
"empty list of jobs returns empty diff"
);
};
subtest "2 different jobs" => sub {
my $ret = buildDiff([$builds->{"succeed_with_failed"}], [$builds->{"empty_dir"}]);
is($ret->{stillSucceed}, [], "stillSucceed");
is($ret->{stillFail}, [], "stillFail");
is($ret->{nowSucceed}, [], "nowSucceed");
is($ret->{nowFail}, [], "nowFail");
is($ret->{unfinished}, [], "unfinished");
is($ret->{aborted}, [], "aborted");
is(scalar(@{$ret->{new}}), 1, "list of new jobs is 1 element long");
is(
$ret->{new}[0]->get_column('id'),
$builds->{"succeed_with_failed"}->get_column('id'),
"succeed_with_failed is a new job"
);
is(scalar(@{$ret->{failed}}), 1, "list of failed jobs is 1 element long");
is(
$ret->{failed}[0]->get_column('id'),
$builds->{"succeed_with_failed"}->get_column('id'),
"succeed_with_failed is a failed job"
);
is(
$ret->{removed},
[
{
job => $builds->{"empty_dir"}->get_column('job'),
system => $builds->{"empty_dir"}->get_column('system')
}
],
"empty_dir is a removed job"
);
};
subtest "failed job with no previous history" => sub {
my $ret = buildDiff([$builds->{"fails"}], []);
is(scalar(@{$ret->{failed}}), 1, "list of failed jobs is 1 element long");
is(
$ret->{failed}[0]->get_column('id'),
$builds->{"fails"}->get_column('id'),
"fails is a failed job"
);
};
subtest "not-yet-built job with no previous history" => sub {
my $builds = $ctx->makeAndEvaluateJobset(
expression => "build-products.nix",
build => 0
);
my $ret = buildDiff([$builds->{"simple"}], []);
is($ret->{stillSucceed}, [], "stillSucceed");
is($ret->{stillFail}, [], "stillFail");
is($ret->{nowSucceed}, [], "nowSucceed");
is($ret->{nowFail}, [], "nowFail");
is($ret->{removed}, [], "removed");
is($ret->{unfinished}, [], "unfinished");
is($ret->{aborted}, [], "aborted");
is($ret->{failed}, [], "failed");
is(scalar(@{$ret->{new}}), 1, "list of new jobs is 1 element long");
is(
$ret->{new}[0]->get_column('id'),
$builds->{"simple"}->get_column('id'),
"simple is a new job"
);
};
done_testing;