<!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** Resolves https://github.com/fleetdm/confidential/issues/13775 Feature branch merging into main, so all code should be reviewed --------- Co-authored-by: Sarah Gillespie <73313222+gillespi314@users.noreply.github.com>
42 lines
893 B
Go
42 lines
893 B
Go
// Automatically generated by mockimpl. DO NOT EDIT!
|
|
|
|
package mock
|
|
|
|
import (
|
|
"context"
|
|
"sync"
|
|
"time"
|
|
|
|
"github.com/fleetdm/fleet/v4/server/fleet"
|
|
)
|
|
|
|
var _ fleet.KeyValueStore = (*KeyValueStore)(nil)
|
|
|
|
type SetFunc func(ctx context.Context, key string, value string, expireTime time.Duration) error
|
|
|
|
type GetFunc func(ctx context.Context, key string) (*string, error)
|
|
|
|
type KeyValueStore struct {
|
|
SetFunc SetFunc
|
|
SetFuncInvoked bool
|
|
|
|
GetFunc GetFunc
|
|
GetFuncInvoked bool
|
|
|
|
mu sync.Mutex
|
|
}
|
|
|
|
func (kv *KeyValueStore) Set(ctx context.Context, key string, value string, expireTime time.Duration) error {
|
|
kv.mu.Lock()
|
|
kv.SetFuncInvoked = true
|
|
kv.mu.Unlock()
|
|
return kv.SetFunc(ctx, key, value, expireTime)
|
|
}
|
|
|
|
func (kv *KeyValueStore) Get(ctx context.Context, key string) (*string, error) {
|
|
kv.mu.Lock()
|
|
kv.GetFuncInvoked = true
|
|
kv.mu.Unlock()
|
|
return kv.GetFunc(ctx, key)
|
|
}
|