build-products: switch to makeAndEvaluateJobset

This commit is contained in:
Graham Christensen 2021-12-14 20:32:13 -05:00
parent 7333d444c6
commit 008321d972

View file

@ -1,43 +1,36 @@
use strict; use strict;
use warnings; use warnings;
use Setup; use Setup;
my %ctx = test_init();
require Hydra::Schema;
require Hydra::Model::DB;
use Test2::V0; use Test2::V0;
my $db = Hydra::Model::DB->new; my $ctx = test_context();
hydra_setup($db);
# Test build products # Test build products
my $jobset = createBaseJobset("build-products", "build-products.nix", $ctx{jobsdir}); my $builds = $ctx->makeAndEvaluateJobset(
expression => "build-products.nix",
build => 1
);
ok(evalSucceeds($jobset), "Evaluating jobs/build-products.nix should exit with return code 0"); subtest "For the build job 'simple'" => sub {
is(nrQueuedBuildsForJobset($jobset), 2, "Evaluating jobs/build-products.nix should result in 2 builds"); my $build = $builds->{"simple"};
for my $build (queuedBuildsForJobset($jobset)) { is($build->finished, 1, "Build should have finished");
subtest "For the build job '" . $build->job . "'" => sub { is($build->buildstatus, 0, "Build should have buildstatus 0");
ok(runBuild($build), "Build should exit with return code 0");
my $newbuild = $db->resultset('Builds')->find($build->id);
is($newbuild->finished, 1, "Build should have finished"); my $buildproduct = $build->buildproducts->next;
is($newbuild->buildstatus, 0, "Build should have buildstatus 0");
my $buildproducts = $db->resultset('BuildProducts')->search({ build => $build->id });
my $buildproduct = $buildproducts->next;
if($build->job eq "simple") {
is($buildproduct->name, "text.txt", "We should have \"text.txt\""); is($buildproduct->name, "text.txt", "We should have \"text.txt\"");
} elsif ($build->job eq "with_spaces") { };
is($buildproduct->name, "some text.txt", "We should have: \"some text.txt\"");
} subtest "For the build job 'with_spaces'" => sub {
}; my $build = $builds->{"with_spaces"};
is($build->finished, 1, "Build should have finished");
is($build->buildstatus, 0, "Build should have buildstatus 0");
my $buildproduct = $build->buildproducts->next;
is($buildproduct->name, "some text.txt", "We should have: \"some text.txt\"");
};
}
done_testing; done_testing;