END block cleanup.

This commit is contained in:
Colin Kuskie 2010-06-14 18:24:21 -07:00
parent 6c3369d0cb
commit 94699417a7
3 changed files with 18 additions and 41 deletions

View file

@ -23,15 +23,9 @@ my $session = WebGUI::Test->session;
# Tests
plan tests => 94;
my ( $s, $t1 );
my $tp = use_ok('TAP::Parser');
my $tpa = use_ok('TAP::Parser::Aggregator');
SKIP: {
skip "Unable to load TAP::Parser and TAP::Parser::Aggregator", 88 unless $tp && $tpa;
#----------------------------------------------------------------------------
# put your tests here
use_ok('WebGUI::Asset::Wobject::Survey::Test');
@ -44,8 +38,9 @@ WebGUI::Test->originalConfig('enableSurveyExpressionEngine');
$session->config->set('enableSurveyExpressionEngine', 1);
# Create a Survey
$s = $import_node->addChild( { className => 'WebGUI::Asset::Wobject::Survey', } );
my $s = $import_node->addChild( { className => 'WebGUI::Asset::Wobject::Survey', } );
isa_ok( $s, 'WebGUI::Asset::Wobject::Survey' );
WebGUI::Test->addToCleanup($s);
my $sJSON = $s->surveyJSON;
@ -155,7 +150,8 @@ cmp_deeply(
'surveyOrderIndex correct'
);
$t1 = WebGUI::Asset::Wobject::Survey::Test->create( $session, { assetId => $s->getId } );
my $t1 = WebGUI::Asset::Wobject::Survey::Test->create( $session, { assetId => $s->getId } );
WebGUI::Test->addToCleanup(sub {$t1->delete();});
my $spec;
# No tests
@ -725,11 +721,8 @@ Hashes differ on element: a
got : '1'
expect : '2'
END_CMP
}
#----------------------------------------------------------------------------
# Cleanup
END {
$s->purge() if $s;
$t1->delete() if $t1;
}

View file

@ -34,6 +34,7 @@ plan tests => 55; # Increment this number for each test you create
# check table structure
WebGUI::Crud->crud_createTable($session);
WebGUI::Test->addToCleanup(sub { WebGUI::Crud->crud_dropTable($session); });
my $sth = $session->db->read("describe unnamed_crud_table");
my ($col, $type) = $sth->array();
is($col, 'id', "structure: id name");
@ -139,11 +140,4 @@ is(WebGUI::Crud->crud_getTableKey($session), 'id', 'default key is id');
is(WebGUI::Crud->crud_getTableName($session), 'unnamed_crud_table', 'default table is unnamed_crud_table');
is(WebGUI::Crud->crud_getSequenceKey($session), '', 'default sequence key is blank');
#----------------------------------------------------------------------------
# Cleanup
END {
WebGUI::Crud->crud_dropTable($session);
}
#vim:ft=perl

View file

@ -23,11 +23,13 @@ use Test::More;
use Test::Exception;
use URI;
plan tests => 20; # increment this value for each test you create
plan tests => 19; # increment this value for each test you create
my $session = WebGUI::Test->session;
$session->user({userId => 3});
my $admin = $session->user;
WebGUI::Test->addToCleanup(sub { WebGUI::Test->cleanupAdminInbox; });
WebGUI::Test->addToCleanup(SQL => "delete from mailQueue where message like '%Threshold=15%'");
my $inbox = WebGUI::Inbox->new($session);
my $import = WebGUI::Asset->getImportNode($session);
@ -121,7 +123,7 @@ my $uri = URI->new($url);
is($uri->path, $posters->getUrl, 'Link in message has correct URL path');
is($uri->query, 'func=editVariant;vid='.$marilynVarId, 'Link in message has function and variant id');
wipeMessages($inbox, $admin);
WebGUI::Test->cleanupAdminInbox;
is(scalar @{$inbox->getMessagesForUser($admin)}, 0, 'All messages deleted');
$instance1->delete;
@ -147,6 +149,13 @@ $message = $inbox->getMessagesForUser($admin)->[0];
note "Test that the workflow does not die when encountering bad assets";
my $otherPosters = $posters->duplicate;
WebGUI::Test->addToCleanup(sub {
$session->db->write("delete from asset where assetId=?",[$otherPosters->getId]);
$session->db->write("delete from assetData where assetId=?",[$otherPosters->getId]);
$session->db->write("delete from sku where assetId=?",[$otherPosters->getId]);
$session->db->write("delete from Product where assetId=?",[$otherPosters->getId]);
$session->db->write("delete from assetIndex where assetId=?",[$otherPosters->getId]);
});
my $movie_posters = $import->addChild({
className => 'WebGUI::Asset::Sku::Product',
url => 'movie_posters',
@ -180,7 +189,7 @@ is($retVal, 'done', 'Workflow is done');
$messages = $inbox->getMessagesForUser($admin);
is(scalar @{$messages}, 1, 'Received one message');
wipeMessages($inbox, $admin);
WebGUI::Test->cleanupAdminInbox;
my $instance4 = WebGUI::Workflow::Instance->create($session,
{
@ -198,24 +207,5 @@ is($retVal, 'done', 'Workflow is done');
$messages = $inbox->getMessagesForUser($admin);
is(scalar @{$messages}, 1, 'Still received one message');
wipeMessages($inbox, $admin);
END {
wipeMessages($inbox, $admin);
$messages = $inbox->getMessagesForUser($admin);
is(scalar @{$messages}, 0, 'Inbox cleaned up');
$session->db->write("delete from mailQueue where message like '%Threshold=15%'");
$session->db->write("delete from asset where assetId=?",[$otherPosters->getId]);
$session->db->write("delete from assetData where assetId=?",[$otherPosters->getId]);
$session->db->write("delete from sku where assetId=?",[$otherPosters->getId]);
$session->db->write("delete from Product where assetId=?",[$otherPosters->getId]);
$session->db->write("delete from assetIndex where assetId=?",[$otherPosters->getId]);
}
sub wipeMessages {
my ($inbox, $user) = @_;
foreach my $message (@{ $inbox->getMessagesForUser($user) }) {
$message->delete;
}
}
#vim:ft=perl