[Bps-public-commit] r9444 - RT-Extension-SLA/t

ruz at bestpractical.com ruz at bestpractical.com
Wed Oct 24 18:00:16 EDT 2007


Author: ruz
Date: Wed Oct 24 18:00:15 2007
New Revision: 9444

Modified:
   RT-Extension-SLA/t/starts.t

Log:
* basic tests for Starts date are ready and things even work

Modified: RT-Extension-SLA/t/starts.t
==============================================================================
--- RT-Extension-SLA/t/starts.t	(original)
+++ RT-Extension-SLA/t/starts.t	Wed Oct 24 18:00:15 2007
@@ -13,21 +13,57 @@
 
 use_ok 'RT::Ticket';
 
+use_ok 'RT::Extension::SLA';
+
+my $bhours = RT::Extension::SLA->BusinessHours;
+
+diag 'check Starts date';
+{
+    %RT::SLA = (
+        Default => 'start',
+        Levels => {
+            'starts' => {
+                Response => 2*60,
+                Resolve => 7*60*24,
+            },
+        },
+    );
+
+    my $time = time;
+
+    my $ticket = RT::Ticket->new( $RT::SystemUser );
+    my ($id) = $ticket->Create( Queue => 'General', Subject => 'xxx' );
+    ok $id, "created ticket #$id";
+
+    my $starts = $ticket->StartsObj->Unix;
+    ok $starts > 0, 'Starts date is set';
+    if ( $bhours->first_after($time) == $time ) {
+        # in hours
+        ok $starts - $time < 5, 'Starts is quite correct';
+    } else {
+        ok $starts - $time > 5 , 'Starts is quite correct';
+    }
+}
+
+diag 'check Starts date with StartImmediately enabled';
 {
     %RT::SLA = (
         Default => 'start immediately',
         Levels => {
             'start immediately' => {
                 StartImmediately => 1,
-                Response => { RealMinutes => 2*60 },
+                Response => 2*60,
+                Resolve => 7*60*24,
             },
         },
     );
+    my $time = time;
 
     my $ticket = RT::Ticket->new( $RT::SystemUser );
     my ($id) = $ticket->Create( Queue => 'General', Subject => 'xxx' );
     ok $id, "created ticket #$id";
 
     ok $ticket->StartsObj->Unix > 0, 'Starts date is set';
+    ok abs($starts - $time) < 5, 'Starts is quite correct';
 }
 



More information about the Bps-public-commit mailing list