From 43c056bb7bd34a3f1012ba41ae3692795e3b5ca2 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Tue, 19 Oct 2021 22:38:50 -0400 Subject: [PATCH] t/TaskDispatcher.t: array / arrayref consistency Also fixes a test which was comparing the length of two lists instead of the values inside the lists. Dang, Perl. --- t/TaskDispatcher.t | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/t/TaskDispatcher.t b/t/TaskDispatcher.t index c055ce45..4bf3e8ed 100644 --- a/t/TaskDispatcher.t +++ b/t/TaskDispatcher.t @@ -87,24 +87,23 @@ sub make_fake_record { subtest "dispatch_event" => sub { subtest "every plugin gets called once, even if it fails all of them." => sub { - my @plugins = [make_noop_plugin("bogus-1"), make_noop_plugin("bogus-2")]; + my $plugins = [make_noop_plugin("bogus-1"), make_noop_plugin("bogus-2")]; - my $dispatcher = Hydra::TaskDispatcher->new($db, $prometheus, @plugins); + my $dispatcher = Hydra::TaskDispatcher->new($db, $prometheus, $plugins); my $event = make_failing_event("bogus-channel"); $dispatcher->dispatch_event($event); is(@{$event->{"called_with"}}, 2, "Both plugins should be called"); - my @expected_names = [ "bogus-1", "bogus-2" ]; - my @actual_names = sort([ - $event->{"called_with"}[0]->name, - $event->{"called_with"}[1]->name - ]); - + my @expected_names = ( "bogus-1", "bogus-2" ); + my @actual_names = sort( + $event->{"called_with"}[0]->name, + $event->{"called_with"}[1]->name + ); is( - @actual_names, - @expected_names, + \@actual_names, + \@expected_names, "Both plugins should be executed, but not in any particular order." ); }; @@ -113,9 +112,9 @@ subtest "dispatch_event" => sub { subtest "dispatch_task" => sub { subtest "every plugin gets called once" => sub { my $bogus_plugin = make_noop_plugin("bogus-1"); - my @plugins = [$bogus_plugin, make_noop_plugin("bogus-2")]; + my $plugins = [$bogus_plugin, make_noop_plugin("bogus-2")]; - my $dispatcher = Hydra::TaskDispatcher->new($db, $prometheus, @plugins); + my $dispatcher = Hydra::TaskDispatcher->new($db, $prometheus, $plugins); my $event = make_fake_event("bogus-channel"); my $task = Hydra::Task->new($event, ref $bogus_plugin); @@ -132,9 +131,9 @@ subtest "dispatch_task" => sub { subtest "a task with an invalid plugin is not fatal" => sub { my $bogus_plugin = make_noop_plugin("bogus-1"); - my @plugins = [$bogus_plugin, make_noop_plugin("bogus-2")]; + my $plugins = [$bogus_plugin, make_noop_plugin("bogus-2")]; - my $dispatcher = Hydra::TaskDispatcher->new($db, $prometheus, @plugins); + my $dispatcher = Hydra::TaskDispatcher->new($db, $prometheus, $plugins); my $event = make_fake_event("bogus-channel"); my $task = Hydra::Task->new($event, "this-plugin-does-not-exist");