luci: go.chromium.org/luci/common/tsmon/store/storetest Index | Files

package storetest

import "go.chromium.org/luci/common/tsmon/store/storetest"

Package storetest is imported exclusively by tests for Store implementations.

Index

Package Files

testing.go

func RunStoreImplementationTests Uses

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.

type FakeMetric Uses

type FakeMetric struct {
    types.MetricInfo
    types.MetricMetadata
}

FakeMetric is a fake Metric implementation.

func (*FakeMetric) Info Uses

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

Info implements Metric.Info

func (*FakeMetric) Metadata Uses

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

Metadata implements Metric.Metadata

func (*FakeMetric) SetFixedResetTime Uses

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

SetFixedResetTime implements Metric.SetFixedResetTime.

type Store Uses

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

    Get(c context.Context, m types.Metric, resetTime time.Time, fieldVals []interface{}) interface{}
    Set(c context.Context, m types.Metric, resetTime time.Time, fieldVals []interface{}, value interface{})
    Incr(c context.Context, m types.Metric, resetTime time.Time, fieldVals []interface{}, delta interface{})

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

    Reset(c 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 Uses

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.

Package storetest imports 14 packages (graph). Updated 2018-12-14. Refresh now. Tools for package owners.