From 7333d444c6a107d5ba422388c296b6f9514f0f13 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Tue, 14 Dec 2021 20:25:54 -0500 Subject: [PATCH] evaluate-basic.t: move to makeAndEvaluateJobset --- t/evaluate-basic.t | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/t/evaluate-basic.t b/t/evaluate-basic.t index d3f21564..2e96930d 100644 --- a/t/evaluate-basic.t +++ b/t/evaluate-basic.t @@ -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;