RT::Shredder test suite utilities
The shredder distribution has several files to help write new tests.
lib/RT/Test/Shredder.pm - this file, utilities
t/shredder/00skeleton.t - skeleteton .t file for new tests
All tests follow this algorithm:
use RT::Test::Shredder tests => undef; # plug in utilities
my $test = "RT::Test::Shredder"; # alias for RT::Test::Shredder
# create RT data you want to be always in the RT DB
# ...
$test->create_savepoint('clean'); # create DB savepoint
# create data you want delete with shredder
# ...
# run shredder on the objects you've created
# ...
# check that shredder deletes things you want
# this command will compare savepoint DB with current
cmp_deeply( $test->dump_current_and_savepoint('mysp'), "current DB equal to savepoint");
# then you can create another object and delete it, then check again
# ...
done_testing();
Savepoints are named and you can create two or more savepoints.
Returns the absolute file path to the current DB. It is <RT::Test-temp_directory . "rt5test" >>.
Returns connected DBI DB handle.
Takes path to sqlite db.
Creates and returns a new RT::Shredder object.
Returns the absolute path to the named savepoint DB file. Takes one argument - savepoint name, by default sp.
Creates savepoint DB from the current DB. Takes name of the savepoint as argument.
Restores current DB to savepoint state. Takes name of the savepoint as argument.
Returns DB dump as a complex hash structure: { TableName => { #id => { lc_field => 'value', } } }
Takes named argument CleanDates. If true, clean all date fields from dump. True by default.
If there are parts of the DB which can change from creating and deleting a queue, skip them when doing the comparison. One example is the global queue cache attribute on RT::System which will be updated on Queue creation and can't be rolled back by the shredder. It may actually make sense for Shredder to be updating this at some point in the future.
Returns dump of the current DB and of the named savepoint. Takes one argument - savepoint name.
Returns the same data as dump_current_and_savepoint function, but in reversed order.