From 86cb482c1b31e410062a044619262ffb09ea4532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Joaqu=C3=ADn=20Atria?= Date: Sun, 21 Jan 2018 18:57:29 +0000 Subject: [PATCH] Use Test::MockTime to stop the passage of time in tests --- dist.ini | 1 + t/rand_time.t | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dist.ini b/dist.ini index 77a8e54..9044a44 100644 --- a/dist.ini +++ b/dist.ini @@ -41,3 +41,4 @@ GD = 0 [Prereqs / TestRequires] Test::More = 0.88 File::Temp = 0 +Test::MockTime = 0 diff --git a/t/rand_time.t b/t/rand_time.t index 3912096..9e0eb16 100644 --- a/t/rand_time.t +++ b/t/rand_time.t @@ -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(); @@ -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 ];