I recently was looking at Test::MockObject as a means of faking a database in a test suite I am currently working on. But then it occured to me, what about a mock DBI driver. I looked around on CPAN, but could not find anything of the sort (at least not with the search terms I was using), I even poked around Google, but everything was coming up Java. So i decided I should give it a whirl myself. I have downloaded DBD::Template as well as DBD::FIle (the "default" driver supplied with DBI), and started digging through them. But before I go to far, I thought I would ask the monastary to see if I am re-inventing the wheel here already.

Has anyone either done this, or heard of someone doing this? Or ever tried to do this before and failed/gave up for whatever reason? Also I would invite comment on the idea itself, any thoughts on what it should be able to do, etc, etc. I am only really in the researching stage so far, so I am open to any ideas.

Update To Clarify
The idea is not so much to do tests on a file or memory based DB, but to be able to interact transparently with DBI and have the Driver be able to validate the tests in a way. In particular in cases of dynamically generated SQL, as opposed to straight DBI interaction.

Another Update
lachoy wrote DBD::Mock, which is exactly what I was looking for (pays to ask before you jump in I guess). I have been using it all day today with much success, I recommend it to other who might have similar needs. Excellent job lachoy!

-stvn

In reply to Has anyone ever written DBD::MockDB by stvn

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.