From 2c6487b8d7fc5355a03066d3d669cdc7a0b249f3 Mon Sep 17 00:00:00 2001 From: Cole Helbling Date: Fri, 28 Jan 2022 10:27:34 -0800 Subject: [PATCH] t/Helper: test constructRunCommandLogPath --- t/Hydra/Helper/Nix.t | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/t/Hydra/Helper/Nix.t b/t/Hydra/Helper/Nix.t index eec77551..8abb60ea 100644 --- a/t/Hydra/Helper/Nix.t +++ b/t/Hydra/Helper/Nix.t @@ -4,6 +4,7 @@ use Setup; use File::Temp; my $ctx = test_context(); +my $db = $ctx->db(); 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;