[CDBI] Mocking CDBI classes

William Ross will at spanner.org
Tue Sep 27 21:21:11 BST 2005

On 27 Sep 2005, at 17:48, Rob Kinyon wrote:

> Is there a Class::DBI::Mock in the works? If not, what's the
> recommended method for mocking CDBI classes?

I was really enjoying this question until I realised that you meant  
mock as in 'pretend' and not 'taunt'.

> On a related note, how hard would it be to write Class::DBI::Mock?

I like the idea of presenting a fake database layer and observing  
both sides, which I now realise is what you mean, but with cdbi one  
is nearly always combining the results of multiple queries. Even the  
apparently simple $object->update() call involves both an UPDATE and  
(at least one) SELECT query. In practice your mock database would  
have to act very much like a real database, which is why people  
normally use SQLite.

See eg the cdbi test suite.

I like the question, though. I hate building sqlite databases just to  
run tests, with all the nasty MakeFile hacking that inevitably  
follows. Ideally I'd like there to be a standard cdbi test database  
included in the distribution and available to everyone. Then we could  
all use that.



More information about the ClassDBI mailing list