Help-Site Computer Manuals
Software
Hardware
Programming
Networking
  Algorithms & Data Structures   Programming Languages   Revision Control
  Protocols
  Cameras   Computers   Displays   Keyboards & Mice   Motherboards   Networking   Printers & Scanners   Storage
  Windows   Linux & Unix   Mac

/var/sites/help-site.com/auto/tmp/CPAN/9677/RTx-Shredder-0.07/t/utils.pl

/var/sites/help-site.com/auto/tmp/CPAN/9677/RTx-Shredder-0.07/t/utils.pl


DESCRIPTION

RTx::Shredder test suite utilities.


TESTING

Since RTx::Shredder 0.01_03 we have test suite. You can run tests and see if everything works as expected before you try shredder on your actual data. Tests also help in the development process.

Test suite uses SQLite databases to store data in individual files, so you could sun tests on your production servers and be in safe.

You want to run test suite almost everytime you install/update shredder distribution. Especialy you want do it if you have local customizations of the DB schema and/or RT code.

Tests is one thing you can write even if don't know perl much, but want to learn more about RT. New tests are very welcome.

WRITING TESTS

Shredder distribution has several files to help write new tests.


  t/utils.pl - this file, utilities

  t/00skeleton.t - skeleteton .t file for new test files

All tests runs by next algorithm:


  require "t/utils.pl"; # plug in utilities

  init_db(); # create new tmp RT DB and init RT API

  # create RT data you want to be always in the RT DB

  # ...

  create_savepoint('mysp'); # 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( dump_current_and_savepoint('mysp'), "current DB equal to savepoint");

  # then you can create another data and delete it then check again

Savepoints are named and you can create two or more savepoints.


FUNCTIONS

RT CONFIG

rewrite_rtconfig

Call this sub after RT::LoadConfig. Function changes RT config option to switch to local SQLite database.

config_set

DATABASES

init_db

Creates new RT DB with initial data in the test tmp dir. Remove old files in the tmp dir if exist. Also runs RT::Init() and init logging. This is all you need to call to setup testing environment in common situation.

db_name

Returns absolute file path to the current DB. It is cwd() .'/t/data/tmp/'. test_name() .'.db'. See also test_name function.

connect_sqlite

Returns connected DBI DB handle. Takes path to sqlite db.

SHREDDER

shredder_new

TEST FILES

test_name

Returns name of the test file running now with stripped extension and dir names. For exmple returns '00load' for 't/00load.t' test file.

TEMPORARY DIRECTORY

tmpdir

Return absolute path to tmp dir used in tests. It is cwd(). "t/data/tmp".

create_tmpdir

Creates tmp dir if doesn't exist. Returns tmpdir absolute path.

cleanup_tmp

Delete all tmp files that match t/data/tmp/test_name.* mask. See also test_name function.

SAVEPOINTS

savepoint_name

Returns absolute path to the named savepoint DB file. Takes one argument - savepoint name, by default sp.

create_savepoint

Creates savepoint DB from the current. 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 complex hash structure: { TableName => { #id => { lc_field => 'value', } } }

Takes named argument CleanDates. If true clean all date fields from dump. True by default.

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.

NOTES

Function that return debug notes.

note_on_fail

Returns note about debug info you can find if test failed.

note_not_patched

Returns note about patch if RT looks like not patched.

OTHER

is_all_seccessful

Returns true if all tests you've already run are successful.

Programminig
Wy
Wy
yW
Wy
Programming
Wy
Wy
Wy
Wy