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 warnings;
use Setup;
my %ctx = test_init();
require Hydra::Schema;
require Hydra::Model::DB;
use Test2::V0;
my $db = Hydra::Model::DB->new;
hydra_setup($db);
my $ctx = test_context();
# 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");
is(nrQueuedBuildsForJobset($jobset), 2, "Evaluating jobs/build-products.nix should result in 2 builds");
subtest "For the build job 'simple'" => sub {
my $build = $builds->{"simple"};
for my $build (queuedBuildsForJobset($jobset)) {
subtest "For the build job '" . $build->job . "'" => sub {
ok(runBuild($build), "Build should exit with return code 0");
my $newbuild = $db->resultset('Builds')->find($build->id);
is($build->finished, 1, "Build should have finished");
is($build->buildstatus, 0, "Build should have buildstatus 0");
is($newbuild->finished, 1, "Build should have finished");
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") {
my $buildproduct = $build->buildproducts->next;
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;