[Rt-commit] r2896 - rt/branches/CHALDEA-EXPERIMENTAL/lib/t/regression

autrijus at bestpractical.com autrijus at bestpractical.com
Wed May 18 13:40:02 EDT 2005


Author: autrijus
Date: Wed May 18 13:40:02 2005
New Revision: 2896

Modified:
   rt/branches/CHALDEA-EXPERIMENTAL/lib/t/regression/15cf_combo_cascade.t
   rt/branches/CHALDEA-EXPERIMENTAL/lib/t/regression/15cf_pattern.t
Log:
* improved diagnostics on sanity tests.

Modified: rt/branches/CHALDEA-EXPERIMENTAL/lib/t/regression/15cf_combo_cascade.t
==============================================================================
--- rt/branches/CHALDEA-EXPERIMENTAL/lib/t/regression/15cf_combo_cascade.t	(original)
+++ rt/branches/CHALDEA-EXPERIMENTAL/lib/t/regression/15cf_combo_cascade.t	Wed May 18 13:40:02 2005
@@ -1,16 +1,14 @@
 #!/usr/bin/perl
 use warnings;
 use strict;
-use Test::More qw/no_plan/;
+use Test::More tests => 11;
 
 use RT;
 RT::LoadConfig();
 RT::Init();
 
-sub fail_ok {
-    my ($cond, $msg) = @_;
-    ok(!$cond, "This should fail: $msg");
-}
+sub fails { ok(!$_[0], "This should fail: $_[1]") }
+sub works { ok($_[0], $_[1] || 'This works') }
 
 sub new (*) {
     my $class = shift;
@@ -18,33 +16,34 @@
 }
 
 my $q = new(RT::Queue);
-ok($q->Create(Name => "CF-Pattern-".$$));
+works($q->Create(Name => "CF-Pattern-".$$));
 
 my $cf = new(RT::CustomField);
 my @cf_args = (Name => $q->Name, Type => 'Combobox', Queue => $q->id);
 
-ok($cf->Create(@cf_args));
+works($cf->Create(@cf_args));
 
 # Set some CFVs with Category markers
 
 my $t = new(RT::Ticket);
 my ($id,undef,$msg) = $t->Create(Queue => $q->id, Subject => 'CF Test');
-ok($id,$msg);
+works($id,$msg);
 
-sub add_ok {
-    my ($id, $msg) = $cf->AddValue(Name => $_[0], Description => $_[0], Category => $_[1]);
-    ok($id, $msg);
+sub add_works {
+    works(
+        $cf->AddValue(Name => $_[0], Description => $_[0], Category => $_[1])
+    );
 };
 
-add_ok('value1', '1. Category A');
-add_ok('value2');
-add_ok('value3', '1.1. A-sub one');
-add_ok('value4', '1.2. A-sub two');
-add_ok('value5', '');
+add_works('value1', '1. Category A');
+add_works('value2');
+add_works('value3', '1.1. A-sub one');
+add_works('value4', '1.2. A-sub two');
+add_works('value5', '');
 
 my $cfv = $cf->Values->First;
 is($cfv->Category, '1. Category A');
-ok($cfv->SetCategory('1. Category AAA'));
+works($cfv->SetCategory('1. Category AAA'));
 is($cfv->Category, '1. Category AAA');
 
 1;

Modified: rt/branches/CHALDEA-EXPERIMENTAL/lib/t/regression/15cf_pattern.t
==============================================================================
--- rt/branches/CHALDEA-EXPERIMENTAL/lib/t/regression/15cf_pattern.t	(original)
+++ rt/branches/CHALDEA-EXPERIMENTAL/lib/t/regression/15cf_pattern.t	Wed May 18 13:40:02 2005
@@ -1,16 +1,14 @@
 #!/usr/bin/perl
 use warnings;
 use strict;
-use Test::More qw/no_plan/;
+use Test::More tests => 13;
 
 use RT;
 RT::LoadConfig();
 RT::Init();
 
-sub fail_ok {
-    my ($cond, $msg) = @_;
-    ok(!$cond, "This should fail: $msg");
-}
+sub fails { ok(!$_[0], "This should fail: $_[1]") }
+sub works { ok($_[0], $_[1] || 'This works') }
 
 sub new (*) {
     my $class = shift;
@@ -18,31 +16,31 @@
 }
 
 my $q = new(RT::Queue);
-ok($q->Create(Name => "CF-Pattern-".$$));
+works($q->Create(Name => "CF-Pattern-".$$));
 
 my $cf = new(RT::CustomField);
 my @cf_args = (Name => $q->Name, Type => 'Freeform', Queue => $q->id);
 
-fail_ok($cf->Create(@cf_args, Pattern => ')))bad!regex((('));
-ok($cf->Create(@cf_args, Pattern => 'good regex'));
+fails($cf->Create(@cf_args, Pattern => ')))bad!regex((('));
+works($cf->Create(@cf_args, Pattern => 'good regex'));
 
 my $t = new(RT::Ticket);
 my ($id,undef,$msg) = $t->Create(Queue => $q->id, Subject => 'CF Test');
-ok($id,$msg);
+works($id,$msg);
 
 # OK, I'm thoroughly brain washed by HOP at this point now...
 sub cnt { $t->CustomFieldValues($cf->id)->Count };
 sub add { $t->AddCustomFieldValue(Field => $cf->id, Value => $_[0]) };
 
 is(cnt(), 0, "No values yet");
-fail_ok(add('not going to match'));
+fails(add('not going to match'));
 is(cnt(), 0, "No values yet");
-ok(add('here is a good regex'));
+works(add('here is a good regex'));
 is(cnt(), 1, "Value filled");
 
-fail_ok($cf->SetPattern('(?{ "insert evil code here" })'));
-ok($cf->SetPattern('(?!)')); # reject everything
-fail_ok(add(''));
-fail_ok(add('...'));
+fails($cf->SetPattern('(?{ "insert evil code here" })'));
+works($cf->SetPattern('(?!)')); # reject everything
+fails(add(''));
+fails(add('...'));
 
 1;


More information about the Rt-commit mailing list