Help us shape the future of Go! Take the 2026 Go Developer Survey

fake

package
v1.19.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

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

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) Close

func (f *Fake) Close() error

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 (*Fake) GetComponentMetadata

func (f *Fake) GetComponentMetadata() metadata.MetadataMap

func (*Fake) Init

func (f *Fake) Init(ctx context.Context, md binarystore.Metadata) error

func (*Fake) Set

func (f *Fake) Set(ctx context.Context, req *binarystore.SetRequest) error

func (*Fake) WithClose

func (f *Fake) WithClose(fn func() error) *Fake

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) WithInit

func (f *Fake) WithInit(fn func(ctx context.Context, metadata binarystore.Metadata) error) *Fake

func (*Fake) WithSet

func (f *Fake) WithSet(fn func(ctx context.Context, req *binarystore.SetRequest) error) *Fake

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL