@Ken: I looked into mocking a (very little) bit. I don't have any experience with it but I'm worried about the need to sync the 'real' database with my mocked functions. Using the real schema is appealing because I don't have to worry about synchronization issues.
@Shantanu: This looks great! I've also recently started thinking about the best way to migrate changes (I've been doing it by hand, but they've been small changes). I'll look into this more. Thanks for the input. Tim On May 8, 4:33 am, Shantanu Kumar <kumar.shant...@gmail.com> wrote: > On May 8, 8:37 am, Tim McIver <tmci...@verizon.net> wrote: > > > I'm looking for some input as to the best way to test functions that > > interact with a database. I've just started writing some tests for > > functions that read/write to a mysql database (using > > clojure.contrib.sql) but my problem is that I'd like the tests to > > begin with either an empty database or one that has been initialized > > with some known data. Some of my functions add/remove data from the > > You may like to consider Clj-Liquibase for some of these > jobs:https://bitbucket.org/kumarshantanu/clj-liquibase/srchttp://www.liquibase.org/manual/home(most > of the Change types are > supported by Clj-Liquibase) > > You can load seed data using Liquibase and have the schema dropped/re- > created/migrated as required before every test case. Coupling this > with your own setup functions for various test scenarios may be a good > compromise. Of course, every test needs to call the appropriate setup > function to prepare the DB. > > > database and so some of these tests will fail if run again on the > > changed database. I was thinking I'd have a fixture that loaded a > > mysql dump file before running the tests but I haven't found any way > > to do this in Clojure. Any suggestions? > > Loading SQL statements from the dump file and replaying them can be > done using JDBC, but setting up the DB for every test case and > cleaning up afterwards will still need to be handled. JDBC > distinguishes between queries (SELECT) and updates (DML, DDL) in the > API, which is something you will need to take care of. > > Regards, > Shantanu -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en