Documentation
¶
Overview ¶
Package fake provides a fake BinaryStore implementation for tests of components and runtimes that consume a binary store. It is not a user-facing component and so it does not ship component metadata.
Following the convention used elsewhere in Dapr, Fake holds one function field per interface method and exposes a WithXxx builder for each, so a test can make an individual operation fail on demand:
store := fake.New().WithGet(func(context.Context, *binarystore.GetRequest) (*binarystore.GetResponse, error) {
return nil, errors.New("boom")
})
Every field defaults to the in-memory binary store, so a Fake that overrides nothing behaves like a real store while holding all data in process memory. That makes it usable both for wiring tests that just need a working store and for exercising a consumer's error handling.
NewFake is the registry-shaped constructor, taking a logger and returning binarystore.BinaryStore, so the fake can be registered as a component in the same way as a real binary store.
Index ¶
- func NewFake(log logger.Logger) binarystore.BinaryStore
- type Fake
- func (f *Fake) Close() error
- func (f *Fake) Delete(ctx context.Context, req *binarystore.DeleteRequest) error
- func (f *Fake) Features() []binarystore.Feature
- func (f *Fake) Get(ctx context.Context, req *binarystore.GetRequest) (*binarystore.GetResponse, error)
- func (f *Fake) GetComponentMetadata() metadata.MetadataMap
- func (f *Fake) Init(ctx context.Context, md binarystore.Metadata) error
- func (f *Fake) Set(ctx context.Context, req *binarystore.SetRequest) error
- func (f *Fake) WithClose(fn func() error) *Fake
- func (f *Fake) WithDelete(fn func(ctx context.Context, req *binarystore.DeleteRequest) error) *Fake
- func (f *Fake) WithFeatures(fn func() []binarystore.Feature) *Fake
- func (f *Fake) WithGet(...) *Fake
- func (f *Fake) WithGetComponentMetadata(fn func() metadata.MetadataMap) *Fake
- func (f *Fake) WithInit(fn func(ctx context.Context, metadata binarystore.Metadata) error) *Fake
- func (f *Fake) WithSet(fn func(ctx context.Context, req *binarystore.SetRequest) error) *Fake
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewFake ¶
func NewFake(log logger.Logger) binarystore.BinaryStore
NewFake returns a Fake backed by the in-memory binary store, using the given logger. It has the constructor shape expected by the component registry (func(logger.Logger) binarystore.BinaryStore) so it can be registered directly; use New for the fluent WithXxx builder API.
Types ¶
type Fake ¶
type Fake struct {
// contains filtered or unexported fields
}
Fake is a configurable fake implementation of binarystore.BinaryStore.
func New ¶
func New() *Fake
New returns a Fake whose operations are all backed by the in-memory binary store. Use the WithXxx builders to override individual operations.
func (*Fake) Delete ¶
func (f *Fake) Delete(ctx context.Context, req *binarystore.DeleteRequest) error
func (*Fake) Features ¶
func (f *Fake) Features() []binarystore.Feature
func (*Fake) Get ¶
func (f *Fake) Get(ctx context.Context, req *binarystore.GetRequest) (*binarystore.GetResponse, error)
func (*Fake) GetComponentMetadata ¶
func (f *Fake) GetComponentMetadata() metadata.MetadataMap
func (*Fake) Set ¶
func (f *Fake) Set(ctx context.Context, req *binarystore.SetRequest) error
func (*Fake) WithDelete ¶
func (f *Fake) WithDelete(fn func(ctx context.Context, req *binarystore.DeleteRequest) error) *Fake
func (*Fake) WithFeatures ¶
func (f *Fake) WithFeatures(fn func() []binarystore.Feature) *Fake
func (*Fake) WithGet ¶
func (f *Fake) WithGet(fn func(ctx context.Context, req *binarystore.GetRequest) (*binarystore.GetResponse, error)) *Fake
func (*Fake) WithGetComponentMetadata ¶
func (f *Fake) WithGetComponentMetadata(fn func() metadata.MetadataMap) *Fake
func (*Fake) WithSet ¶
func (f *Fake) WithSet(fn func(ctx context.Context, req *binarystore.SetRequest) error) *Fake