Skip to content

Commit

Permalink
Use Test::MockTime to stop the passage of time in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jjatria committed Jan 24, 2018
1 parent c977d08 commit 86cb482
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions dist.ini
Expand Up @@ -41,3 +41,4 @@ GD = 0
[Prereqs / TestRequires]
Test::More = 0.88
File::Temp = 0
Test::MockTime = 0
4 changes: 2 additions & 2 deletions t/rand_time.t
Expand Up @@ -2,8 +2,10 @@ use strict;
use warnings;

use Test::More;
use Test::MockTime qw( set_fixed_time );
use Data::Random qw( rand_time );

set_fixed_time('2018-01-21T18:54:00Z');

# Test default w/ no params
test_range();
Expand All @@ -19,8 +21,6 @@ test_range('9:0:0', '10:0:0');

# Test min + max options using "now"
{
# Technically, the clock could roll over to a new second between these two statements.
# But I don't think I'm going to worry about it unless we see a failure here from CPAN Testers.
my $time = rand_time( min => 'now', max => 'now' );
my ( $hour, $min, $sec ) = ( localtime() )[ 2, 1, 0 ];

Expand Down

0 comments on commit 86cb482

Please sign in to comment.