test: add unit test for Items (#2703)
Signed-off-by: Guangwen Feng <fenggw-fnst@fujitsu.com>
This commit is contained in:
parent
170a7f2186
commit
6c07550032
|
|
@ -24,6 +24,8 @@ import (
|
|||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
testifyassert "github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -185,6 +187,16 @@ func TestCacheKeys(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestItems(t *testing.T) {
|
||||
tc := New(DefaultExpiration, 0)
|
||||
tc.Set(v1, "1", 1)
|
||||
tc.Set(v2, "2", DefaultExpiration)
|
||||
tc.Set(v3, "3", DefaultExpiration)
|
||||
m := tc.Items()
|
||||
assert := testifyassert.New(t)
|
||||
assert.Equal(map[string]Item{"bar": {Object: "2", Expiration: 0}, "baz": {Object: "3", Expiration: 0}}, m)
|
||||
}
|
||||
|
||||
func TestItemCount(t *testing.T) {
|
||||
tc := New(DefaultExpiration, 0)
|
||||
tc.Set(v1, "1", DefaultExpiration)
|
||||
|
|
|
|||
Loading…
Reference in New Issue