Rewrite the DeleteExpiredSessions test to not take cheap shortcuts

that are not very reliable.
This commit is contained in:
Colin Kuskie 2009-02-20 22:31:03 +00:00
parent 179e75ef8f
commit 8b06f912ca

View file

@ -19,12 +19,33 @@ use WebGUI::Workflow::Activity::DeleteExpiredSessions;
use Test::More; use Test::More;
plan tests => 5; # increment this value for each test you create plan tests => 7; # increment this value for each test you create
my $session = WebGUI::Test->session; my $session = WebGUI::Test->session;
my $activity = WebGUI::Workflow::Activity::DeleteExpiredSessions->create($session); my $workflow = WebGUI::Workflow->create($session,
$activity->execute(); ##Clear out any old sessions that might interfere with this test; {
enabled => 1,
objectType => 'None',
mode => 'realtime',
},
);
my $activity = $workflow->addActivity('WebGUI::Workflow::Activity::DeleteExpiredSessions');
my $instance1 = WebGUI::Workflow::Instance->create($session,
{
workflowId => $workflow->getId,
skipSpectreNotification => 1,
}
);
my $retVal;
$retVal = $instance1->run();
is($retVal, 'complete', 'cleanup: activity complete');
$retVal = $instance1->run();
is($retVal, 'done', 'cleanup: activity is done');
$instance1->delete;
my $origSessionTimeout = $session->setting->get('sessionTimeout'); my $origSessionTimeout = $session->setting->get('sessionTimeout');
@ -55,8 +76,20 @@ my $newScratchCount = $session->db->quickScalar('select count(*) from userSessio
is ($newSessionCount, $sessionCount+4, 'all new sessions created correctly'); is ($newSessionCount, $sessionCount+4, 'all new sessions created correctly');
is ($newScratchCount, $scratchCount+2, 'two of the new sessions have scratch entries'); is ($newScratchCount, $scratchCount+2, 'two of the new sessions have scratch entries');
my $returnValue = $activity->execute(); my $instance2 = WebGUI::Workflow::Instance->create($session,
is ($returnValue, 'complete', 'DeleteExpiredSessions completed'); {
workflowId => $workflow->getId,
skipSpectreNotification => 1,
}
);
my $counter = 0;
PAUSE: while ($retVal = $instance2->run()) {
last PAUSE if $retVal eq 'done';
last PAUSE if $counter > 6; #Emergency exit clause
}
is($retVal, 'done', 'Workflow completed successfully');
$newSessionCount = $session->db->quickScalar('select count(*) from userSession'); $newSessionCount = $session->db->quickScalar('select count(*) from userSession');
$newScratchCount = $session->db->quickScalar('select count(*) from userSessionScratch'); $newScratchCount = $session->db->quickScalar('select count(*) from userSessionScratch');