[Xapian-discuss] Fwd: Clearing Database For Tests

Ryan Bates ryan at railscasts.com
Tue Nov 3 00:06:25 GMT 2009


On Mon, Nov 2, 2009 at 3:58 PM, David P. Novakovic
<davidnovakovic at gmail.com> wrote:
> The alternative that I have used a fair bit is to have an empty db as a
> fixture somewhere and copy it to a new location for each test/suite

Yeah, I'll save that as a last resort if there are no other solutions. :)

I find it strange that generating a new database takes so long. I
imagine a cached copy of a blank database could be included with
Xapian so it would be nearly instantaneous.

Regards,

Ryan


> On Tue, Nov 3, 2009 at 9:56 AM, Ryan Bates <ryan at railscasts.com> wrote:
>>
>> Hi David,
>>
>> Thanks for the response. Unfortunately mocking isn't a solution here.
>> I'm actually building a high-level wrapper around the Xapian bindings
>> so nearly every test interacts heavily with the Xapian database:
>> http://github.com/ryanb/xapit
>>
>> Would love to hear more ideas though.
>>
>> Regards,
>>
>> Ryan
>>
>>
>> On Mon, Nov 2, 2009 at 3:46 PM, David P. Novakovic
>> <davidnovakovic at gmail.com> wrote:
>> > I forgot to cc the mailing list...
>> >
>> > ---------- Forwarded message ----------
>> > From: David P. Novakovic <davidnovakovic at gmail.com>
>> > Date: Tue, Nov 3, 2009 at 9:45 AM
>> > Subject: Re: [Xapian-discuss] Clearing Database For Tests
>> > To: Ryan Bates <ryan at railscasts.com>
>> >
>> >
>> > i know this doesn't answer your question, but it is definitely worth
>> > mentioning:
>> >
>> > I've found that I actually don't need that many tests for interface code
>> > to
>> > xapian.  Once you have tests that prove your base wrapper functions work
>> > as
>> > expected wouldn't you just want to test your code not xapian?
>> >
>> > Use mocks and dep injection to avoid actually touching the xapian
>> > code...
>> > I've forgotten the technical term for it, but you want to avoid testing
>> > code
>> > that is outside of the scope of what you are trying to test.
>> >
>> >
>> > On Tue, Nov 3, 2009 at 9:36 AM, Ryan Bates <ryan at railscasts.com> wrote:
>> >
>> >> I am using Xapian through the Ruby bindings and am wondering the best
>> >> way to use it in a unit test suite where we must start with an empty
>> >> database every time (so records generated in one test don't interfere
>> >> with another). I am currently deleting the database directory and
>> >> regenerating it every time, but I find this to be very slow (nearly
>> >> half a second). This results in even a small number of tests taking a
>> >> long time to run.
>> >>
>> >> Is there some fast way to clear an existing database of all content
>> >> (terms, values, spellings, etc.)? If not, what is the best practice
>> >> for resetting a database for each test?
>> >>
>> >> Regards,
>> >>
>> >> Ryan
>> >>
>> >> _______________________________________________
>> >> Xapian-discuss mailing list
>> >> Xapian-discuss at lists.xapian.org
>> >> http://lists.xapian.org/mailman/listinfo/xapian-discuss
>> >>
>> > _______________________________________________
>> > Xapian-discuss mailing list
>> > Xapian-discuss at lists.xapian.org
>> > http://lists.xapian.org/mailman/listinfo/xapian-discuss
>> >
>
>



More information about the Xapian-discuss mailing list