mirror of
https://github.com/1f349/cache.git
synced 2024-09-19 01:56:44 +01:00
17 lines
349 B
Go
17 lines
349 B
Go
|
package cache
|
||
|
|
||
|
import (
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
"testing"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
func TestItem_HasExpired(t *testing.T) {
|
||
|
n := time.Now()
|
||
|
a := item[string]{expires: n}
|
||
|
timeNow = func() time.Time { return n.Add(time.Second) }
|
||
|
assert.True(t, a.HasExpired())
|
||
|
a = item[string]{expires: n.Add(time.Second * 2)}
|
||
|
assert.False(t, a.HasExpired())
|
||
|
}
|