Module of the day: Test::DatabaseRow

jplindstrom on 2004-03-17T16:32:07

We now use the promising-looking Test::DatabaseRow that I found in the comments in a previous journal entry.

It's very useful and perfectly solves the problem at hand -- whitebox testing the behind-the-scenes database stuff we previously only tested the API for.

It's a good thing because... well, the third test found a bug (yay us!).

Like I mentioned, I see the need for comparing the number of rows for a certain query before/after a test. I'll probably end up implementing something like that and see what kind of easy-to-use interface it should have.

Right now I think it's something like:

my $sql = "select * from blah where my_id = $id";

rows_added_ok($sql); #do stuff that should add two rows rows_added_ok($sql, 2, "Stuff() inserted into blah"); #do stuff that should add one more row rows_added_ok($sql, 1, "Stuff() inserted into blah");


I imagine I should key the previous value to the "$dbh.$sql".