2022-02-02 11:18:05 +00:00
|
|
|
package pool
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestSessionCache_GetAccessTime(t *testing.T) {
|
|
|
|
const key = "Foo"
|
|
|
|
|
2022-03-11 11:57:35 +00:00
|
|
|
cache, err := newCache()
|
2022-02-02 11:18:05 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
cache.Put(key, nil)
|
|
|
|
|
|
|
|
t1, ok := cache.GetAccessTime(key)
|
|
|
|
require.True(t, ok)
|
|
|
|
|
|
|
|
time.Sleep(10 * time.Millisecond)
|
|
|
|
|
|
|
|
t2, ok := cache.GetAccessTime(key)
|
|
|
|
require.True(t, ok)
|
|
|
|
require.Equal(t, t1, t2)
|
|
|
|
|
|
|
|
_ = cache.Get(key)
|
|
|
|
t3, ok := cache.GetAccessTime(key)
|
|
|
|
require.True(t, ok)
|
|
|
|
require.NotEqual(t, t1, t3)
|
|
|
|
}
|