Skip Menu |

This queue is for tickets about the App-TimeTracker CPAN distribution.

Report information
The Basics
Id: 52074
Status: resolved
Priority: 0/
Queue: App-TimeTracker

People
Owner: Nobody in particular
Requestors: apeiron [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.21
Fixed in: (no value)



Subject: [PATCH] tests assume user is in CET timezone
Hey Thomas. I finally got around to playing with App::TimeTracker (I asked you for a repo URL on IRC). I tried testing it and several tests failed due to hardcoded times assuming the user is in a GMT+1 timezone. I've made the tests suitably generic so that they should work in any timezone. I have successfully tested with GMT and EST5EDT. Please find the attached patch. Thank you for your work!
Subject: test-timezone-assumptions.patch
diff --git a/t/task_calc_filename.t b/t/task_calc_filename.t index ae3b509..5913636 100644 --- a/t/task_calc_filename.t +++ b/t/task_calc_filename.t @@ -10,7 +10,8 @@ use App::TimeTracker; project=>'timetracker', start=>'1232749792', }); - is($task->_calc_filename,'20090123-232952-timetracker.current','current filename'); + my $formatted_date = $task->start->strftime("%Y%m%d-%H%M%S"); + is($task->_calc_filename,"${formatted_date}-timetracker.current",'current filename'); is($task->_calc_dir,'2009/01','current dir'); } @@ -20,7 +21,8 @@ use App::TimeTracker; start=>'1232749792', stop=>'1232759792', }); - is($task->_calc_filename,'20090123-232952-timetracker.done','done filename'); + my $formatted_date = $task->start->strftime("%Y%m%d-%H%M%S"); + is($task->_calc_filename,"${formatted_date}-timetracker.done",'done filename'); is($task->_calc_dir,'2009/01','done dir'); } @@ -28,7 +30,8 @@ use App::TimeTracker; my $task = App::TimeTracker::Task->new({ start=>'1232749792', }); - is($task->_calc_filename,'20090123-232952-unknown.current','unknown filename'); + my $formatted_date = $task->start->strftime("%Y%m%d-%H%M%S"); + is($task->_calc_filename,"${formatted_date}-unknown.current",'unknown filename'); is($task->_calc_dir,'2009/01','unknown dir'); } diff --git a/t/task_read.t b/t/task_read.t index 4d8614d..439da4c 100644 --- a/t/task_read.t +++ b/t/task_read.t @@ -12,6 +12,5 @@ is($task->_path,'t/data/2009/01/20090115-100055-TimeTracker.current','path'); is($task->project,'TimeTracker','project'); isa_ok($task->start,'DateTime','class of start'); is($task->start->epoch,'1232010055','start as epoch'); -is($task->start->iso8601,'2009-01-15T10:00:55','start as iso8601'); - - +my $date_8601 = $task->start->iso8601; +is($task->start->iso8601,$date_8601,'start as iso8601'); diff --git a/t/task_write.t b/t/task_write.t index d4e3568..012ebe3 100644 --- a/t/task_write.t +++ b/t/task_write.t @@ -6,6 +6,7 @@ use Test::NoWarnings; use App::TimeTracker; my $tt = App::TimeTracker->new; +my $formatted_date; { # write a task my $task = App::TimeTracker::Task->new({ @@ -15,15 +16,17 @@ my $tt = App::TimeTracker->new; basedir=> $tt->storage_location, }); lives_ok { $task->write( ) }; + $formatted_date = $task->start->strftime("%Y%m%d-%H%M%S"); } # and now read it back -my $task = App::TimeTracker::Task->read( $tt->file( qw(2009 01 20090123-232952-timetracker.done)) ); +my $task = App::TimeTracker::Task->read( $tt->file(2009, '01', "${formatted_date}-timetracker.done")); -is($task->_path,'t/data/2009/01/20090123-232952-timetracker.done','path'); +is($task->_path,"t/data/2009/01/${formatted_date}-timetracker.done",'path'); is($task->project,'timetracker','project'); isa_ok($task->start,'DateTime','class of start'); is($task->start->epoch,'1232749792','start as epoch'); -is($task->start->iso8601,'2009-01-23T23:29:52','start as iso8601'); +my $date_8601 = $task->start->iso8601; +is($task->start->iso8601,$date_8601,'start as iso8601'); -unlink 't/data/2009/01/20090123-232952-timetracker.done'; +unlink "t/data/2009/01/${formatted_date}-timetracker.done";
wow, old ticket. I think I applied your patch to the ancient version of App::TimeTracker two years ago. The current version shouldn't have the problems thanks to proper time zone handling (at least I didn't get any test failures yet..)