From fbce3b6ed1fa9f136ec53729c81449f1ae84aa4e Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Tue, 14 Dec 2021 20:52:40 -0500 Subject: [PATCH] default-machine-file: use makeAndEvaluateJobset --- t/queue-runner/default-machine-file.t | 31 ++++++++------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/t/queue-runner/default-machine-file.t b/t/queue-runner/default-machine-file.t index e6348226..ae38938b 100644 --- a/t/queue-runner/default-machine-file.t +++ b/t/queue-runner/default-machine-file.t @@ -2,34 +2,21 @@ use feature 'unicode_strings'; use strict; use warnings; use Setup; +use Test2::V0; -my %ctx = test_init( +my $ctx = test_context( nix_config => q| system-features = test-system-feature | ); -require Hydra::Schema; -require Hydra::Model::DB; +my $builds = $ctx->makeAndEvaluateJobset( + expression => "default-machine-file.nix", + build => 1, +); -use Test2::V0; - -my $db = Hydra::Model::DB->new; -hydra_setup($db); - -my $project = $db->resultset('Projects')->create({name => "tests", displayname => "", owner => "root"}); - -my $jobset = createBaseJobset("default-machine-file", "default-machine-file.nix", $ctx{jobsdir}); - -ok(evalSucceeds($jobset), "Evaluating jobs/default-machine-file.nix should exit with return code 0"); -is(nrQueuedBuildsForJobset($jobset), 1, "Evaluating jobs/default-machine-file.nix should result in 1 build"); - -for my $build (queuedBuildsForJobset($jobset)) { - ok(runBuild($build), "Build '".$build->job."' from jobs/default-machine-file.nix should exit with return code 0"); - my $newbuild = $db->resultset('Builds')->find($build->id); - is($newbuild->finished, 1, "Build '".$build->job."' from jobs/default-machine-file.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/default-machine-file.nix should have buildstatus $expected."); -} +my $build = $builds->{"requireExperimentalFeatures"}; +is($build->finished, 1, "Build should be finished."); +is($build->buildstatus, 0, "Build status should be zero"); done_testing;