I use mysqldump to do my testing. If I already have a database I start with
mysqldump -d database > test_database.schema echo create database test_database | mysql mysql test_database < test_database.schema
Now when I am creating/updating tests I can:
mysqldump test_database > test_database.schema
Then I can recursively do
mysql test_database < test_database.schema mysql test_database < alter_database mysql test_database < add_test_data ./Build test
until I am happy with the tests. Then when I install of the new code base I should only need to run
mysql database < alter_database
as an additional step. I then use this code to make sure that the databases have the same structure.
use Algorithm::Diff; my @a = grep( !/Database:/, split('\n', `mysqldump -d tasker`)); my @b = grep( !/Database:/, split('\n', `mysqldump -d test_tasker`)); my $diff = Algorithm::Diff->new( \@a, \@b ); while($diff->Next()) { next if $diff->Same(); next if /Database:/; print "< $_\n" for $diff->Items(1); print "> $_\n" for $diff->Items(2); }
-- gam3
A picture is worth a thousand words, but takes 200K.

In reply to Re: A Framework for automated DB testing by gam3
in thread A Framework for automated DB testing by Mutant

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.