From dd53243b08c38a0774e7f38bb0eb065539e7d33a Mon Sep 17 00:00:00 2001 From: Chris Nehren Date: Fri, 2 Nov 2007 19:12:16 +0000 Subject: [PATCH] Fixups for the tests. I moved the nested key checking into a TODO block. I'm not sure how to handle them, as they may / may not exist in the %output hash. Sometimes they'll pass, sometimes they won't, depending upon the time you run it and the status of Spectre overall. --- lib/Spectre/Workflow.pm | 9 ++++----- t/Spectre/Workflow.t | 30 ++++++++++++++++++------------ 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/lib/Spectre/Workflow.pm b/lib/Spectre/Workflow.pm index 67924b43f..18008bd25 100644 --- a/lib/Spectre/Workflow.pm +++ b/lib/Spectre/Workflow.pm @@ -273,9 +273,6 @@ sub getJsonStatus { my ($kernel, $request, $self) = @_[KERNEL,ARG0,OBJECT]; my ($sitename, $rsvp) = @$request; - # only return this site's info - #return $kernel->call(IKC=>post=>$rsvp, '{}') unless $sitename; - my %queues = (); tie %queues, 'Tie::IxHash'; %queues = ( @@ -291,11 +288,13 @@ sub getJsonStatus { if ($count > 0) { for my $queueItem ($queue->peek_items(sub {1})) { my($priority, $id, $instance) = @{$queueItem}; - # it's not a hash ref, we haven't seen it yet + # The site's name in the list of %output keys isn't a hashref; + # we haven't seen it yet if(ref $output{$instance->{sitename}} ne 'HASH') { $output{$instance->{sitename}} = {}; } - # it's not an array ref, we haven't seen it yet + # The queue name in the $output{sitename} hashref isn't an + # arrayref; we haven't seen it yet if(ref $output{$instance->{sitename}}{$queueName} ne 'ARRAY') { $output{$instance->{sitename}}{$queueName} = []; } diff --git a/t/Spectre/Workflow.t b/t/Spectre/Workflow.t index 1ed17538f..3e6bb78a6 100755 --- a/t/Spectre/Workflow.t +++ b/t/Spectre/Workflow.t @@ -11,7 +11,8 @@ use FindBin; use strict; -use lib "$FindBin::Bin/../lib", "/data/wre/lib"; +use warnings; +use lib "$FindBin::Bin/../lib", "../../wre/lib"; use WebGUI::Test; use WebGUI::Session; use Spectre::Admin; @@ -42,8 +43,9 @@ my $spectreConfig = Config::JSON->new($spectreConfigFile); my $ip = $spectreConfig->get('ip'); my $port = $spectreConfig->get('port'); -# put your tests here - +# need to declare these before the skip block so that they're also visible in +# the todo block +my ($structure, $sitename); SKIP: { skip "need modperl, modproxy, and spectre running to test", 10 unless ($isModPerlRunning && $isModProxyRunning && $isSpectreRunning); # XXX kinda evil kludge to put an activity in the scheduler so that the @@ -70,16 +72,20 @@ SKIP: { ok(defined $result, 'can call getJsonStatus'); $remote->disconnect; undef $remote; - my $structure; ok($structure = jsonToObj($result), 'workflow/getJsonStatus returns a proper JSON data structure'); - diag(Dumper $structure); cmp_ok(ref $structure, 'eq', 'HASH', 'workflow/getJsonStatus returns a JSON structure parseable into a Perl hashref'); - my $sitename = $session->config->get('sitename')->[0]; + $sitename = $session->config->get('sitename')->[0]; ok(exists $structure->{$sitename}, "$sitename exists in returned structure"); - for my $key(qw/Suspended Waiting Running/) { - ok(exists $structure->{$sitename}{$key}, "$key exists for $sitename"); - cmp_ok(ref $structure->{$sitename}{$key}, 'eq', 'HASH', "$key is a hashref in the $sitename hash"); - } - - +} + +# Not sure how to handle these; the problem is that there may or may not be +# items in each queue type, and specifically constructing each key for each +# sitename in getJsonStatus even though they may not have data seems a bit +# contrived and kludgish. +TODO: { + local $TODO = "tests to make later."; + for my $key(qw/Suspended Waiting Running/) { + ok(exists $structure->{$sitename}{$key}, "$key exists for $sitename"); + cmp_ok(ref $structure->{$sitename}{$key}, 'eq', 'ARRAY', "$key is an arrayref in the $sitename hash"); + } }