You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
690 B
Go
29 lines
690 B
Go
2 years ago
|
package cache
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
"time"
|
||
|
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
|
func TestCacheOptions(t *testing.T) {
|
||
|
t.Run("default options", func(t *testing.T) {
|
||
|
o := newOptions()
|
||
|
assert.Equal(t, defaultExpiry, o.Expiry)
|
||
|
assert.Equal(t, defaultNotFoundExpiry, o.NotFoundExpiry)
|
||
|
})
|
||
|
|
||
|
t.Run("with expiry", func(t *testing.T) {
|
||
|
o := newOptions(WithExpiry(time.Second))
|
||
|
assert.Equal(t, time.Second, o.Expiry)
|
||
|
assert.Equal(t, defaultNotFoundExpiry, o.NotFoundExpiry)
|
||
|
})
|
||
|
|
||
|
t.Run("with not found expiry", func(t *testing.T) {
|
||
|
o := newOptions(WithNotFoundExpiry(time.Second))
|
||
|
assert.Equal(t, defaultExpiry, o.Expiry)
|
||
|
assert.Equal(t, time.Second, o.NotFoundExpiry)
|
||
|
})
|
||
|
}
|