evaluate-basic.t: move to makeAndEvaluateJobset

This commit is contained in:
Graham Christensen 2021-12-14 20:25:54 -05:00
parent adfe74b76a
commit 7333d444c6

View file

@ -5,22 +5,31 @@ use Setup;
use Test2::V0;
my $ctx = test_context();
my $db = $ctx->db;
my $project = $db->resultset('Projects')->create({name => "tests", displayname => "", owner => "root"});
my $builds = $ctx->makeAndEvaluateJobset(
expression => "basic.nix",
build => 1
);
# Most basic test case, no parameters
my $jobset = createBaseJobset("basic", "basic.nix", $ctx->jobsdir);
subtest "Build: succeed_with_failed" => sub {
my $build = $builds->{"succeed_with_failed"};
ok(evalSucceeds($jobset), "Evaluating jobs/basic.nix should exit with return code 0");
is(nrQueuedBuildsForJobset($jobset), 3, "Evaluating jobs/basic.nix should result in 3 builds");
is($build->finished, 1, "Build should be finished.");
is($build->buildstatus, 6, "succeeeded-but-failed should have buildstatus 6.");
};
for my $build (queuedBuildsForJobset($jobset)) {
ok(runBuild($build), "Build '".$build->job."' from jobs/basic.nix should exit with return code 0");
my $newbuild = $db->resultset('Builds')->find($build->id);
is($newbuild->finished, 1, "Build '".$build->job."' from jobs/basic.nix should be finished.");
my $expected = $build->job eq "fails" ? 1 : $build->job =~ /with_failed/ ? 6 : 0;
is($newbuild->buildstatus, $expected, "Build '".$build->job."' from jobs/basic.nix should have buildstatus $expected.");
}
subtest "Build: empty_dir" => sub {
my $build = $builds->{"empty_dir"};
is($build->finished, 1, "Build should be finished.");
is($build->buildstatus, 0, "Should have succeeded.");
};
subtest "Build: fails" => sub {
my $build = $builds->{"fails"};
is($build->finished, 1, "Build should be finished.");
is($build->buildstatus, 1, "Should have failed.");
};
done_testing;