Use timeNow variable for time.Now for use with testing

This commit is contained in:
Melon 2025-02-06 21:46:52 +00:00
parent 76230a5bfc
commit 6839f0fc0f
Signed by: melon
GPG Key ID: 6C9D970C50D26A25

View File

@ -110,7 +110,7 @@ func TestCache_Range(t *testing.T) {
}
func TestCache_Cleaner(t *testing.T) {
timeNow = func() time.Time { return time.Now() }
timeNow = time.Now
n := time.Now().Add(2 * time.Second)
c := New[string, string]()
@ -134,7 +134,7 @@ func TestCache_Cleaner(t *testing.T) {
}
func TestCache_UpdateExpiry(t *testing.T) {
timeNow = func() time.Time { return time.Now() }
timeNow = time.Now
c := New[string, string]()
c.Set("a", "b", time.Now().Add(2*time.Second))
@ -154,7 +154,7 @@ func TestCache_UpdateExpiry(t *testing.T) {
}
func TestCache_ClearerDeath(t *testing.T) {
timeNow = func() time.Time { return time.Now() }
timeNow = time.Now
c := New[string, string]()