[Rt-commit] r12574 - in rt/branches/3.8-TESTING: . t/ticket

jesse at bestpractical.com jesse at bestpractical.com
Wed May 21 01:43:34 EDT 2008


Author: jesse
Date: Wed May 21 01:43:34 2008
New Revision: 12574

Modified:
   rt/branches/3.8-TESTING/   (props changed)
   rt/branches/3.8-TESTING/t/ticket/search.t
   rt/branches/3.8-TESTING/t/ticket/search_by_watcher.t
   rt/branches/3.8-TESTING/t/ticket/sort_by_cf.t
   rt/branches/3.8-TESTING/t/web/command_line.t

Log:
 r31794 at 31b:  jesse | 2008-05-21 12:11:37 +0800
 * cleanups to mismerge of tests


Modified: rt/branches/3.8-TESTING/t/ticket/search.t
==============================================================================
--- rt/branches/3.8-TESTING/t/ticket/search.t	(original)
+++ rt/branches/3.8-TESTING/t/ticket/search.t	Wed May 21 01:43:34 2008
@@ -140,67 +140,82 @@
 # we have tickets. start searching
 my $tix = RT::Tickets->new($RT::SystemUser);
 $tix->FromSQL("Queue = '$queue'");
-is($tix->Count, 7, "found all the tickets");
+is($tix->Count, 7, "found all the tickets")
+    or diag "wrong results from SQL:\n". $tix->BuildSelectCountQuery;
 
 
 # very simple searches. both CF and normal
 
 $tix = RT::Tickets->new($RT::SystemUser);
 $tix->FromSQL("Queue = '$queue' AND CF.SearchTest = 'foo1'");
-is($tix->Count, 1, "matched identical subject");
+is($tix->Count, 1, "matched identical subject")
+    or diag "wrong results from SQL:\n". $tix->BuildSelectCountQuery;
 
 $tix = RT::Tickets->new($RT::SystemUser);
 $tix->FromSQL("Queue = '$queue' AND CF.SearchTest LIKE 'foo1'");
-is($tix->Count, 1, "matched LIKE subject");
+is($tix->Count, 1, "matched LIKE subject")
+    or diag "wrong results from SQL:\n". $tix->BuildSelectCountQuery;
 
 $tix = RT::Tickets->new($RT::SystemUser);
 $tix->FromSQL("Queue = '$queue' AND CF.SearchTest = 'foo'");
-is($tix->Count, 0, "IS a regexp match");
+is($tix->Count, 0, "IS a regexp match")
+    or diag "wrong results from SQL:\n". $tix->BuildSelectCountQuery;
 
 $tix = RT::Tickets->new($RT::SystemUser);
 $tix->FromSQL("Queue = '$queue' AND CF.SearchTest LIKE 'foo'");
-is($tix->Count, 5, "matched LIKE subject");
+is($tix->Count, 5, "matched LIKE subject")
+    or diag "wrong results from SQL:\n". $tix->BuildSelectCountQuery;
 
 
 $tix = RT::Tickets->new($RT::SystemUser);
 $tix->FromSQL("Queue = '$queue' AND CF.SearchTest IS NULL");
-is($tix->Count, 2, "IS null CF");
+is($tix->Count, 2, "IS null CF")
+    or diag "wrong results from SQL:\n". $tix->BuildSelectCountQuery;
 
 $tix = RT::Tickets->new($RT::SystemUser);
 $tix->FromSQL("Queue = '$queue' AND Requestors LIKE 'search1'");
-is($tix->Count, 1, "LIKE requestor");
+is($tix->Count, 1, "LIKE requestor")
+    or diag "wrong results from SQL:\n". $tix->BuildSelectCountQuery;
 
 $tix = RT::Tickets->new($RT::SystemUser);
 $tix->FromSQL("Queue = '$queue' AND Requestors = 'search1\@example.com'");
-is($tix->Count, 1, "IS requestor");
+is($tix->Count, 1, "IS requestor")
+    or diag "wrong results from SQL:\n". $tix->BuildSelectCountQuery;
 
 $tix = RT::Tickets->new($RT::SystemUser);
 $tix->FromSQL("Queue = '$queue' AND Requestors LIKE 'search'");
-is($tix->Count, 6, "LIKE requestor");
+is($tix->Count, 6, "LIKE requestor")
+    or diag "wrong results from SQL:\n". $tix->BuildSelectCountQuery;
 
 $tix = RT::Tickets->new($RT::SystemUser);
 $tix->FromSQL("Queue = '$queue' AND Requestors IS NULL");
-is($tix->Count, 1, "Search for no requestor");
+is($tix->Count, 1, "Search for no requestor")
+    or diag "wrong results from SQL:\n". $tix->BuildSelectCountQuery;
 
 $tix = RT::Tickets->new($RT::SystemUser);
 $tix->FromSQL("Queue = '$queue' AND Subject = 'SearchTest1'");
-is($tix->Count, 1, "IS subject");
+is($tix->Count, 1, "IS subject")
+    or diag "wrong results from SQL:\n". $tix->BuildSelectCountQuery;
 
 $tix = RT::Tickets->new($RT::SystemUser);
 $tix->FromSQL("Queue = '$queue' AND Subject LIKE 'SearchTest1'");
-is($tix->Count, 1, "LIKE subject");
+is($tix->Count, 1, "LIKE subject")
+    or diag "wrong results from SQL:\n". $tix->BuildSelectCountQuery;
 
 $tix = RT::Tickets->new($RT::SystemUser);
 $tix->FromSQL("Queue = '$queue' AND Subject = ''");
-is($tix->Count, 1, "found one ticket");
+is($tix->Count, 1, "found one ticket")
+    or diag "wrong results from SQL:\n". $tix->BuildSelectCountQuery;
 
 $tix = RT::Tickets->new($RT::SystemUser);
 $tix->FromSQL("Queue = '$queue' AND Subject LIKE 'SearchTest'");
-is($tix->Count, 6, "found two ticket");
+is($tix->Count, 6, "found two ticket")
+    or diag "wrong results from SQL:\n". $tix->BuildSelectCountQuery;
 
 $tix = RT::Tickets->new($RT::SystemUser);
 $tix->FromSQL("Queue = '$queue' AND Subject LIKE 'qwerty'");
-is($tix->Count, 0, "found zero ticket");
+is($tix->Count, 0, "found zero ticket")
+    or diag "wrong results from SQL:\n". $tix->BuildSelectCountQuery;
 
 
 

Modified: rt/branches/3.8-TESTING/t/ticket/search_by_watcher.t
==============================================================================
--- rt/branches/3.8-TESTING/t/ticket/search_by_watcher.t	(original)
+++ rt/branches/3.8-TESTING/t/ticket/search_by_watcher.t	Wed May 21 01:43:34 2008
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 79;
+use Test::More tests => 103;
 use RT::Test;
 use RT::Ticket;
 
@@ -93,6 +93,37 @@
 }
 run_tests();
 
+# mixing searches by watchers with other conditions
+# http://rt3.fsck.com/Ticket/Display.html?id=9322
+%test = (
+    'Subject LIKE "x" AND Requestor = "y at example.com"' =>
+        { xy => 1, x => 0, y => 0, '-' => 0, z => 0 },
+    'Subject NOT LIKE "x" AND Requestor = "y at example.com"' =>
+        { xy => 0, x => 0, y => 1, '-' => 0, z => 0 },
+    'Subject LIKE "x" AND Requestor != "y at example.com"' =>
+        { xy => 0, x => 1, y => 0, '-' => 0, z => 0 },
+    'Subject NOT LIKE "x" AND Requestor != "y at example.com"' =>
+        { xy => 0, x => 0, y => 0, '-' => 1, z => 1 },
+    'Subject LIKE "x" OR Requestor = "y at example.com"' =>
+        { xy => 1, x => 1, y => 1, '-' => 0, z => 0 },
+    'Subject NOT LIKE "x" OR Requestor = "y at example.com"' =>
+        { xy => 1, x => 0, y => 1, '-' => 1, z => 1 },
+    'Subject LIKE "x" OR Requestor != "y at example.com"' =>
+        { xy => 1, x => 1, y => 0, '-' => 1, z => 1 },
+    'Subject NOT LIKE "x" OR Requestor != "y at example.com"' =>
+        { xy => 0, x => 1, y => 1, '-' => 1, z => 1 },
+
+    'Subject LIKE "z" AND (Requestor = "x at example.com" OR Requestor = "y at example.com")' =>
+        { xy => 0, x => 0, y => 0, '-' => 0, z => 0 },
+    'Subject NOT LIKE "z" AND (Requestor = "x at example.com" OR Requestor = "y at example.com")' =>
+        { xy => 1, x => 1, y => 1, '-' => 0, z => 0 },
+    'Subject LIKE "z" OR (Requestor = "x at example.com" OR Requestor = "y at example.com")' =>
+        { xy => 1, x => 1, y => 1, '-' => 0, z => 1 },
+    'Subject NOT LIKE "z" OR (Requestor = "x at example.com" OR Requestor = "y at example.com")' =>
+        { xy => 1, x => 1, y => 1, '-' => 1, z => 0 },
+);
+run_tests();
+
 TODO: {
     local $TODO = "we can't generate this query yet";
     %test = (
@@ -140,6 +171,7 @@
 }
 run_tests();
 
+
 # owner is special watcher because reference is duplicated in two places,
 # owner was an ENUM field now it's WATCHERFIELD, but should support old
 # style ENUM searches for backward compatibility

Modified: rt/branches/3.8-TESTING/t/ticket/sort_by_cf.t
==============================================================================
--- rt/branches/3.8-TESTING/t/ticket/sort_by_cf.t	(original)
+++ rt/branches/3.8-TESTING/t/ticket/sort_by_cf.t	Wed May 21 01:43:34 2008
@@ -15,6 +15,8 @@
 
 
 # Test Sorting by custom fields.
+# TODO: it's hard to read this file, conver to new style,
+# for example look at 23cfsort-freeform-single.t
 
 # ---- Create a queue to test with.
 my $queue = "CFSortQueue-$$";

Modified: rt/branches/3.8-TESTING/t/web/command_line.t
==============================================================================
--- rt/branches/3.8-TESTING/t/web/command_line.t	(original)
+++ rt/branches/3.8-TESTING/t/web/command_line.t	Wed May 21 01:43:34 2008
@@ -3,7 +3,7 @@
 use strict;
 use Test::Expect;
 #use Test::More qw/no_plan/;
-use Test::More tests => 219;
+use Test::More tests => 223;
 use RT::Test;
 my ($baseurl, $m) = RT::Test->started_ok;
 
@@ -153,6 +153,11 @@
 expect_like(qr/Ticket $ticket_id updated/, 'Changed cf');
 expect_send("show ticket/$ticket_id -f CF-myCF$$", 'Checking new value');
 expect_like(qr/CF-myCF$$: VALUE/i, 'Verified change');
+# Test setting 0 as value of the custom field
+expect_send("edit ticket/$ticket_id set 'CF-myCF$$=0' ", 'Changing CF...');
+expect_like(qr/Ticket $ticket_id updated/, 'Changed cf');
+expect_send("show ticket/$ticket_id -f CF-myCF$$", 'Checking new value');
+expect_like(qr/CF-myCF$$: 0/i, 'Verified change');
 # Test reading and setting custom fields with spaces
 expect_send("show ticket/$ticket_id -f 'CF-my CF$$'", 'Checking initial value');
 expect_like(qr/my CF$$:/i, 'Verified change');


More information about the Rt-commit mailing list