ldtest

package
v4.111.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package ldtest contains types and functions used by SDK unit tests in multiple packages.

Application code should not use this package. In a future version, it will be moved to internal.

Index

Constants

This section is empty.

Variables

View Source
var MockData = mockDataKind{}

MockData is an instance of ld.VersionedDataKind corresponding to MockDataItem.

View Source
var MockOtherData = mockOtherDataKind{}

MockOtherData is an instance of ld.VersionedDataKind corresponding to MockOtherDataItem.

Functions

func RunFeatureStoreConcurrentModificationTests

func RunFeatureStoreConcurrentModificationTests(t *testing.T, store1 ld.FeatureStore, store2 ld.FeatureStore,
	setStore1UpdateHook func(func()))

RunFeatureStoreConcurrentModificationTests runs tests of concurrent modification behavior for store implementations that support testing this.

store1: A FeatureStore instance.

store2: A second FeatureStore instance which will be used to perform concurrent updates.

setStore1UpdateHook: A function which, when called with another function as a parameter, will modify store1 so that it will call the latter function synchronously during each Upsert operation - after the old value has been read, but before the new one has been written.

func RunFeatureStorePrefixIndependenceTests

func RunFeatureStorePrefixIndependenceTests(t *testing.T,
	makeStoreWithPrefix func(string) (ld.FeatureStore, error),
	clearExistingData func() error)

RunFeatureStorePrefixIndependenceTests is for feature store implementations that support storing independent data sets in the same database by assigning a different prefix/namespace to each one. It verifies that two store instances with different prefixes do not interfere with each other's data.

makeStoreWithPrefix: Creates a FeatureStore instance with the specified prefix/namespace, which can be empty. All instances should use the same underlying database. The store should not have caching enabled.

clearExistingData: Removes all data from the underlying store.

func RunFeatureStoreTests

func RunFeatureStoreTests(t *testing.T, storeFactory ld.FeatureStoreFactory, clearExistingData func() error, isCached bool)

RunFeatureStoreTests runs a suite of tests on a feature store.

  • makeStore: Creates a new feature store instance, but does not call Init on it.
  • clearExistingData: If non-nil, this function will be called before each test to clear any storage that the store instances may be sharing. If this is nil, it means store instances do not share any common storage.
  • isCached: True if the instances returned by makeStore have caching enabled.

Types

type MockDataItem

type MockDataItem struct {
	Key     string
	Version int
	Deleted bool
}

MockDataItem is a test implementation of ld.VersionedData.

func (*MockDataItem) GetKey

func (i *MockDataItem) GetKey() string

GetKey returns the item key.

func (*MockDataItem) GetVersion

func (i *MockDataItem) GetVersion() int

GetVersion returns the item version.

func (*MockDataItem) IsDeleted

func (i *MockDataItem) IsDeleted() bool

IsDeleted returns true if this is a deleted item placeholder.

type MockOtherDataItem

type MockOtherDataItem struct {
	Key     string
	Version int
	Deleted bool
}

MockDataItem is a test implementation of ld.VersionedData.

func (*MockOtherDataItem) GetKey

func (i *MockOtherDataItem) GetKey() string

GetKey returns the item key.

func (*MockOtherDataItem) GetVersion

func (i *MockOtherDataItem) GetVersion() int

GetVersion returns the item version.

func (*MockOtherDataItem) IsDeleted

func (i *MockOtherDataItem) IsDeleted() bool

IsDeleted returns true if this is a deleted item placeholder.

Jump to

Keyboard shortcuts

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