--- trunk/t/01swish.t 2004/12/05 22:24:09 21 +++ trunk/t/01swish.t 2004/12/07 16:05:43 22 @@ -2,7 +2,7 @@ use strict; -use Test::More tests => 47; +use Test::More tests => 56; use Test::Exception; use blib; @@ -16,11 +16,13 @@ ## FIXME my $index = '/tmp/swish-pp'; +my $debug = 0; +$debug = 4 if (@ARGV); $i = SWISH::PlusPlus->new( index_dir => $index, meta_in_body => 1, -# debug => 1, + debug => $debug, ); ok($i, "open index"); @@ -61,10 +63,13 @@ cmp_ok(scalar @r, '==', 1, "find $word"); } -# test_find('words to test against meta','meta') +# test_find('words to test against meta','meta', nr_results) sub test_find { my $words = shift || die "no words?"; my $meta = shift; + my $nr = shift; + + $nr = 1 unless defined($nr); foreach my $word (split(/\s+/,$words)) { my $path; @@ -72,10 +77,10 @@ $q = "$meta=($word)" if ($meta); my @r = $i->search($q); - cmp_ok(scalar @r, '==', 1, "search $q"); + cmp_ok(scalar @r, '==', $nr, "search $q - $nr results"); if ($meta) { like($i->property(shift @r, $meta), qr/$word/i, "find $word in $meta property"); - cmp_ok(scalar $i->search("$word"), '==', 1, "find $word anywhere"); + cmp_ok(scalar $i->search("$word"), '==', $nr, "find $word anywhere -- $nr results"); } } @@ -87,3 +92,9 @@ test_find(( $data->{$_} || $data->{'meta'}->{$_} ), $_); } +ok($i->delete("life"), "delete life"); +ok($i->{'_deleted'}->{'life'}, "life marked as deleted"); + +ok($i->finish_update, "finish_update"); + +test_find($data->{'body'}, undef, '0');