storetest

package
v0.0.0-...-1f88c41 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package storetest is imported exclusively by tests for Store implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunStoreImplementationTests

func RunStoreImplementationTests(t *testing.T, ctx context.Context, opts TestOptions)

RunStoreImplementationTests runs all the standard tests that all store implementations are expected to pass. When you write a new Store implementation you should ensure you run these tests against it.

Types

type FakeMetric

type FakeMetric struct {
	types.MetricInfo
	types.MetricMetadata
}

FakeMetric is a fake Metric implementation.

func (*FakeMetric) Info

func (m *FakeMetric) Info() types.MetricInfo

Info implements Metric.Info

func (*FakeMetric) Metadata

func (m *FakeMetric) Metadata() types.MetricMetadata

Metadata implements Metric.Metadata

func (*FakeMetric) SetFixedResetTime

func (m *FakeMetric) SetFixedResetTime(t time.Time)

SetFixedResetTime implements Metric.SetFixedResetTime.

type Store

type Store interface {
	DefaultTarget() types.Target
	SetDefaultTarget(t types.Target)

	Get(ctx context.Context, m types.Metric, resetTime time.Time, fieldVals []any) any
	Set(ctx context.Context, m types.Metric, resetTime time.Time, fieldVals []any, value any)
	Del(ctx context.Context, m types.Metric, fieldVals []any)
	Incr(ctx context.Context, m types.Metric, resetTime time.Time, fieldVals []any, delta any)

	GetAll(ctx context.Context) []types.Cell

	Reset(ctx context.Context, m types.Metric)
}

Store is a store under test.

It is a copy of store.Store interface to break module dependency cycle.

type TestOptions

type TestOptions struct {
	// Factory creates and returns a new Store implementation.
	Factory func() Store

	// RegistrationFinished is called after all metrics have been registered.
	// Store implementations that need to do expensive initialization (that would
	// otherwise be done in iface.go) can do that here.
	RegistrationFinished func(Store)

	// GetNumRegisteredMetrics returns the number of metrics registered in the
	// store.
	GetNumRegisteredMetrics func(Store) int
}

TestOptions contains options for RunStoreImplementationTests.

Jump to

Keyboard shortcuts

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