[Rt-commit] rt branch, 3.9-trunk, updated. rt-3.9.4-242-g4290264

Ruslan Zakirov ruz at bestpractical.com
Tue Nov 2 19:25:00 EDT 2010


The branch, 3.9-trunk has been updated
       via  429026460c34949b4d034c1226168cc5d20e2873 (commit)
      from  36b892f849cee3d0fbc947d2cf3fd05c75bb2037 (commit)

Summary of changes:
 t/fts/{indexed_pg.t => not_indexed.t} |   29 +++--------------------------
 1 files changed, 3 insertions(+), 26 deletions(-)
 copy t/fts/{indexed_pg.t => not_indexed.t} (62%)

- Log -----------------------------------------------------------------
commit 429026460c34949b4d034c1226168cc5d20e2873
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed Nov 3 02:24:12 2010 +0300

    forgot to commit tests for not indexed search

diff --git a/t/fts/not_indexed.t b/t/fts/not_indexed.t
new file mode 100644
index 0000000..9d81647
--- /dev/null
+++ b/t/fts/not_indexed.t
@@ -0,0 +1,57 @@
+#!/usr/bin/perl -w
+
+use strict;
+use warnings;
+
+use RT::Test tests => 9;
+
+RT->Config->Set( FullTextSearch => Enable => 1, Indexed => 0 );
+
+my $q = RT::Test->load_or_create_queue( Name => 'General' );
+ok $q && $q->id, 'loaded or created queue';
+my $queue = $q->Name;
+
+sub run_tests {
+    my @test = @_;
+    while ( my ($query, $checks) = splice @test, 0, 2 ) {
+        run_test( $query, %$checks );
+    }
+}
+
+my @tickets;
+sub run_test {
+    my ($query, %checks) = @_;
+    my $query_prefix = join ' OR ', map 'id = '. $_->id, @tickets;
+
+    my $tix = RT::Tickets->new(RT->SystemUser);
+    $tix->FromSQL( "( $query_prefix ) AND ( $query )" );
+
+    my $error = 0;
+
+    my $count = 0;
+    $count++ foreach grep $_, values %checks;
+    is($tix->Count, $count, "found correct number of ticket(s) by '$query'") or $error = 1;
+
+    my $good_tickets = ($tix->Count == $count);
+    while ( my $ticket = $tix->Next ) {
+        next if $checks{ $ticket->Subject };
+        diag $ticket->Subject ." ticket has been found when it's not expected";
+        $good_tickets = 0;
+    }
+    ok( $good_tickets, "all tickets are good with '$query'" ) or $error = 1;
+
+    diag "Wrong SQL query for '$query':". $tix->BuildSelectQuery if $error;
+}
+
+ at tickets = RT::Test->create_tickets(
+    { Queue => $q->id },
+    { Subject => 'book', Content => 'book' },
+    { Subject => 'bar', Content => 'bar' },
+);
+
+run_tests(
+    "Content LIKE 'book'" => { book => 1, bar => 0 },
+    "Content LIKE 'bar'" => { book => 0, bar => 1 },
+);
+
+

-----------------------------------------------------------------------


More information about the Rt-commit mailing list