@@ -5,6 +5,7 @@ const { deepStrictEqual, notEqual, equal } = require('node:assert')
55const { Readable } = require ( 'node:stream' )
66const { once } = require ( 'node:events' )
77const MemoryCacheStore = require ( '../../lib/cache/memory-cache-store' )
8+ const { nowAbsolute } = require ( '../../lib/util/timers.js' )
89
910cacheStoreTests ( MemoryCacheStore )
1011
@@ -32,9 +33,9 @@ function cacheStoreTests (CacheStore) {
3233 statusCode : 200 ,
3334 statusMessage : '' ,
3435 rawHeaders : [ Buffer . from ( '1' ) , Buffer . from ( '2' ) , Buffer . from ( '3' ) ] ,
35- cachedAt : Date . now ( ) ,
36- staleAt : Date . now ( ) + 10000 ,
37- deleteAt : Date . now ( ) + 20000
36+ cachedAt : nowAbsolute ( ) ,
37+ staleAt : nowAbsolute ( ) + 10000 ,
38+ deleteAt : nowAbsolute ( ) + 20000
3839 }
3940 const requestBody = [ 'asd' , '123' ]
4041
@@ -71,9 +72,9 @@ function cacheStoreTests (CacheStore) {
7172 statusCode : 200 ,
7273 statusMessage : '' ,
7374 rawHeaders : [ Buffer . from ( '1' ) , Buffer . from ( '2' ) , Buffer . from ( '3' ) ] ,
74- cachedAt : Date . now ( ) ,
75- staleAt : Date . now ( ) + 10000 ,
76- deleteAt : Date . now ( ) + 20000
75+ cachedAt : nowAbsolute ( ) ,
76+ staleAt : nowAbsolute ( ) + 10000 ,
77+ deleteAt : nowAbsolute ( ) + 20000
7778 }
7879 const anotherBody = [ 'asd2' , '1234' ]
7980
@@ -108,9 +109,9 @@ function cacheStoreTests (CacheStore) {
108109 statusCode : 200 ,
109110 statusMessage : '' ,
110111 rawHeaders : [ Buffer . from ( '1' ) , Buffer . from ( '2' ) , Buffer . from ( '3' ) ] ,
111- cachedAt : Date . now ( ) - 10000 ,
112- staleAt : Date . now ( ) - 1 ,
113- deleteAt : Date . now ( ) + 20000
112+ cachedAt : nowAbsolute ( ) - 10000 ,
113+ staleAt : nowAbsolute ( ) - 1 ,
114+ deleteAt : nowAbsolute ( ) + 20000
114115 }
115116 const requestBody = [ 'part1' , 'part2' ]
116117
@@ -140,9 +141,9 @@ function cacheStoreTests (CacheStore) {
140141 const requestValue = {
141142 statusCode : 200 ,
142143 statusMessage : '' ,
143- cachedAt : Date . now ( ) - 20000 ,
144- staleAt : Date . now ( ) - 10000 ,
145- deleteAt : Date . now ( ) - 5
144+ cachedAt : nowAbsolute ( ) - 20000 ,
145+ staleAt : nowAbsolute ( ) - 10000 ,
146+ deleteAt : nowAbsolute ( ) - 5
146147 }
147148 const requestBody = [ 'part1' , 'part2' ]
148149
@@ -174,9 +175,9 @@ function cacheStoreTests (CacheStore) {
174175 vary : {
175176 'some-header' : 'hello world'
176177 } ,
177- cachedAt : Date . now ( ) ,
178- staleAt : Date . now ( ) + 10000 ,
179- deleteAt : Date . now ( ) + 20000
178+ cachedAt : nowAbsolute ( ) ,
179+ staleAt : nowAbsolute ( ) + 10000 ,
180+ deleteAt : nowAbsolute ( ) + 20000
180181 }
181182 const requestBody = [ 'part1' , 'part2' ]
182183
0 commit comments