RT 5.0.8 Documentation
RT::Test::Shredder
DESCRIPTION
RT::Shredder test suite utilities
WRITING TESTS
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.
FUNCTIONS
DATABASES
db_name
Returns the absolute file path to the current DB. It is <RT::Test-
temp_directory . "rt5test" >>.
connect_sqlite
Returns connected DBI DB handle.
Takes path to sqlite db.
SHREDDER
shredder_new
Creates and returns a new RT::Shredder object.
SAVEPOINTS
savepoint_name
Returns the absolute path to the named savepoint DB file. Takes one argument - savepoint name, by default sp
.
create_savepoint
Creates savepoint DB from the current DB. Takes name of the savepoint as argument.
restore_savepoint
Restores current DB to savepoint state. Takes name of the savepoint as argument.
DUMPS
dump_sqlite
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.
dump_sqlite_exceptions
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.
dump_current_and_savepoint
Returns dump of the current DB and of the named savepoint. Takes one argument - savepoint name.
dump_savepoint_and_current
Returns the same data as dump_current_and_savepoint
function, but in reversed order.