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 ¶
- Variables
- func RunFeatureStoreConcurrentModificationTests(t *testing.T, store1 ld.FeatureStore, store2 ld.FeatureStore, ...)
- func RunFeatureStorePrefixIndependenceTests(t *testing.T, makeStoreWithPrefix func(string) (ld.FeatureStore, error), ...)
- func RunFeatureStoreTests(t *testing.T, storeFactory ld.FeatureStoreFactory, ...)
- type MockDataItem
- type MockOtherDataItem
Constants ¶
This section is empty.
Variables ¶
var MockData = mockDataKind{}
MockData is an instance of ld.VersionedDataKind corresponding to MockDataItem.
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 ¶
MockDataItem is a test implementation of ld.VersionedData.
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 ¶
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.