t/Helper: test constructRunCommandLogPath

This commit is contained in:
Cole Helbling 2022-01-28 10:27:34 -08:00
parent 8bf3cdbc67
commit 2c6487b8d7

View file

@ -4,6 +4,7 @@ use Setup;
use File::Temp; use File::Temp;
my $ctx = test_context(); my $ctx = test_context();
my $db = $ctx->db();
require Hydra::Helper::Nix; require Hydra::Helper::Nix;
@ -65,4 +66,22 @@ is(Hydra::Helper::Nix::getMachines(), {
}, ":)"); }, ":)");
subtest "constructRunCommandLogPath" => sub {
my $builds = $ctx->makeAndEvaluateJobset(
expression => "basic.nix",
);
my $build = $builds->{"empty_dir"};
my $runlog = $db->resultset('RunCommandLogs')->create({
job_matcher => "*:*:*",
build_id => $build->get_column('id'),
command => "bogus",
});
like(
Hydra::Helper::Nix::constructRunCommandLogPath($runlog),
qr@/runcommand-logs/[0-9a-f]{2}/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}@,
"The constructed RunCommandLog path is sufficiently bucketed and UUID-like."
);
};
done_testing; done_testing;