prysm-pulse/shared/lru/lru_wrpr_test.go
Marcin Górzyński 02966e64d8
Feature lru cache wrapper 2 (#9511)
* Add Wrapper to LRU Cache to handle Invalid Parameters #9461

* Regenerate BUILD.bazel and simplify tests using lru.Cache

* Fix: fuzz_exports.go build error

* Fix: block_fuzz.go

* Revert lru.Cache interface

* Remove redundant err check in pending_attestations_queue_test.go

* Add tests for lru wrapper

* Use lru package in prysm/shared instead of lruwrpr

* Fix: goimports

* Fix: BUILD.bazel

Co-authored-by: Nishant Das <nishdas93@gmail.com>
2021-09-02 18:36:54 +08:00

38 lines
670 B
Go

package lru
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestNew(t *testing.T) {
assert.NotPanics(t, func() {
New(10)
})
}
func TestNew_ZeroOrNegativeSize(t *testing.T) {
assert.Panics(t, func() {
New(0)
})
assert.Panics(t, func() {
New(-1)
})
}
func TestNewWithEvict(t *testing.T) {
assert.NotPanics(t, func() {
NewWithEvict(10, func(key interface{}, value interface{}) {})
})
}
func TestNewWithEvict_ZeroOrNegativeSize(t *testing.T) {
assert.Panics(t, func() {
NewWithEvict(0, func(key interface{}, value interface{}) {})
})
assert.Panics(t, func() {
NewWithEvict(-1, func(key interface{}, value interface{}) {})
})
}