[Bps-public-commit] r9494 - RT-Extension-SLA/t
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Mon Oct 29 10:04:53 EDT 2007
Author: sunnavy
Date: Mon Oct 29 10:04:49 2007
New Revision: 9494
Modified:
RT-Extension-SLA/t/business_hours.t
RT-Extension-SLA/t/queue.t
Log:
use Time::MockTime to test more accurately
Modified: RT-Extension-SLA/t/business_hours.t
==============================================================================
--- RT-Extension-SLA/t/business_hours.t (original)
+++ RT-Extension-SLA/t/business_hours.t Mon Oct 29 10:04:49 2007
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use Test::More tests => 10;
+use Test::More tests => 9;
require 't/utils.pl';
@@ -14,6 +14,11 @@
use_ok 'RT::Ticket';
use_ok 'RT::Extension::SLA';
+use Test::MockTime qw( :all );
+
+# XXX, TODO
+# we assume the RT's Timezone is UTC now, need a smart way to get over that.
+
diag 'check business hours';
{
@@ -26,7 +31,6 @@
},
Monday => {
Resolve => { BusinessMinutes => 60 },
- BusinessHours => 'Default',
},
},
);
@@ -48,7 +52,7 @@
},
);
- my $time = time;
+ set_absolute_time('2007-01-01T00:00:00Z');
my $ticket = RT::Ticket->new($RT::SystemUser);
my ($id) = $ticket->Create( Queue => 'General', Subject => 'xxx' );
@@ -56,17 +60,14 @@
is( $ticket->FirstCustomFieldValue('SLA'), 'Sunday', 'default sla' );
+ my $start = $ticket->StartsObj->Unix;
my $due = $ticket->DueObj->Unix;
- ok( $due > 0, 'Due date is set' );
- ok( $due > $time, 'Due date is in the future');
-
- my ( undef,$min,$hour,$mday,$mon,$year,$wday ) = gmtime( $due );
- is( $wday, 0, 'original due time is on Sunday' );
+ is( $start, 1168160400, 'Start date is 2007-01-07T09:00:00Z' );
+ is( $due, 1168164000, 'Due date is 2007-01-07T10:00:00Z' );
$ticket->AddCustomFieldValue( Field => 'SLA', Value => 'Monday' );
is( $ticket->FirstCustomFieldValue('SLA'), 'Monday', 'new sla' );
$due = $ticket->DueObj->Unix;
- ( undef,$min,$hour,$mday,$mon,$year,$wday ) = gmtime( $due );
- is( $wday, 1, 'new due time is on Monday' );
+ is( $due, 1167645600, 'Due date is 2007-01-01T10:00:00Z' );
}
Modified: RT-Extension-SLA/t/queue.t
==============================================================================
--- RT-Extension-SLA/t/queue.t (original)
+++ RT-Extension-SLA/t/queue.t Mon Oct 29 10:04:49 2007
@@ -14,6 +14,9 @@
use_ok 'RT::Ticket';
use_ok 'RT::Extension::SLA';
+use Test::MockTime qw( :all );
+
+
my $queue = RT::Queue->new($RT::SystemUser);
$queue->Load('General');
@@ -36,21 +39,23 @@
Default => '2',
Levels => {
'2' => { Resolve => { RealMinutes => 60 * 2 } },
- '4' => { Resolve => { RealMinutes => 60 * 4 } },
+ '4' => { StartImmediately => 1, Resolve => { RealMinutes => 60 * 4 } },
},
);
- my $time = time;
+ set_absolute_time('2007-01-01T00:00:00Z');
+ my $time = time;
my $ticket = RT::Ticket->new($RT::SystemUser);
($id) = $ticket->Create( Queue => 'General', Subject => 'xxx' );
- ok $id, "created ticket #$id";
+ ok( $id, "created ticket #$id" );
is $ticket->FirstCustomFieldValue('SLA'), '4', 'default sla';
- my $orig_due = $ticket->DueObj->Unix;
- ok $orig_due > 0, 'Due date is set';
- ok $orig_due > $time, 'Due date is in the future';
+ my $start = $ticket->StartsObj->Unix;
+ my $due = $ticket->DueObj->Unix;
+ is( $start, $time, 'Start Date is right' );
+ is( $due, $time+3600*4, 'Due date is right');
my ( $status, $message ) = $queue->DeleteAttribute('SLA');
ok( $status, $message );
More information about the Bps-public-commit
mailing list