grafana/pkg/infra/remotecache/test_utils.go
Jo f2bf066ad2
SigningKeys: Add jwks endpoint (#76040)
* add jwks

add remote caching

add expose jwks test

tweaks

* fix swagger

* nt
2023-10-05 15:17:31 +02:00

40 lines
796 B
Go

package remotecache
import (
"context"
"time"
)
type FakeCacheStorage struct {
Storage map[string][]byte
}
func (fcs FakeCacheStorage) Set(_ context.Context, key string, value []byte, exp time.Duration) error {
fcs.Storage[key] = value
return nil
}
func (fcs FakeCacheStorage) Get(_ context.Context, key string) ([]byte, error) {
value, exist := fcs.Storage[key]
if !exist {
return nil, ErrCacheItemNotFound
}
return value, nil
}
func (fcs FakeCacheStorage) Delete(_ context.Context, key string) error {
delete(fcs.Storage, key)
return nil
}
func (fcs FakeCacheStorage) Count(_ context.Context, prefix string) (int64, error) {
return int64(len(fcs.Storage)), nil
}
func NewFakeCacheStorage() FakeCacheStorage {
return FakeCacheStorage{
Storage: map[string][]byte{},
}
}