File: Switch-to-Test-MockTime-HiRes-in-date-api-test.diff

package info (click to toggle)
request-tracker4 4.4.6%2Bdfsg-1.1%2Bdeb12u2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 63,460 kB
  • sloc: javascript: 130,444; perl: 65,299; sh: 1,322; makefile: 471; python: 37; php: 30
file content (48 lines) | stat: -rw-r--r-- 1,673 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
From 3ec1c6368deef29d53b77c9431c7b592d2f200eb Mon Sep 17 00:00:00 2001
From: Jim Brandt <jbrandt@bestpractical.com>
Date: Mon, 9 Jan 2023 13:46:58 -0500
Subject: Switch to Test::MockTime::HiRes in date api test

Version 1.14 of DateTime::Format::Natural added support for
milliseconds, which involved changing DateTime calls to
DateTime::HiRes. DateTime::HiRes uses Time::HiRes::time(),
and Test::MockTime doesn't overload that time function. This
resulted in test times being returned as "now" rather than the
mocked time.

Switch to Test::MockTime::HiRes, which does overload the HiRes
time functions. This module also overloads the same time functions
as Test::MockTime, so this change should be compatible with
earlier versions of DateTime::Format::Natural.

Patch-Name: Switch-to-Test-MockTime-HiRes-in-date-api-test.diff
Forwarded: https://github.com/bestpractical/rt/pull/352
Upstream: 4.4.7, commit:8a2430fea5f565039f161c8485ac34496c2ad588
---
 sbin/rt-test-dependencies.in | 1 +
 t/api/date.t                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/sbin/rt-test-dependencies.in b/sbin/rt-test-dependencies.in
index ff1ff755..dcb1554b 100644
--- a/sbin/rt-test-dependencies.in
+++ b/sbin/rt-test-dependencies.in
@@ -234,6 +234,7 @@ Test::Email
 Test::Expect 0.31
 Test::LongString
 Test::MockTime
+Test::MockTime::HiRes
 Test::NoWarnings
 Test::Pod
 Test::Warn
diff --git a/t/api/date.t b/t/api/date.t
index 19a0a015..f97484f8 100644
--- a/t/api/date.t
+++ b/t/api/date.t
@@ -1,5 +1,5 @@
 
-use Test::MockTime qw(set_fixed_time restore_time);
+use Test::MockTime::HiRes qw(set_fixed_time restore_time);
 use DateTime;
 
 use warnings;