go-server-sdk: github.com/launchdarkly/go-server-sdk/shared_test/ldtest Index | Files

package ldtest

import "github.com/launchdarkly/go-server-sdk/shared_test/ldtest"

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

Package Files

feature_store.go mock_data.go

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.

func RunFeatureStoreConcurrentModificationTests Uses

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 Uses

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 Uses

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.

type MockDataItem Uses

type MockDataItem struct {
    Key     string
    Version int
    Deleted bool
}

MockDataItem is a test implementation of ld.VersionedData.

func (*MockDataItem) GetKey Uses

func (i *MockDataItem) GetKey() string

GetKey returns the item key.

func (*MockDataItem) GetVersion Uses

func (i *MockDataItem) GetVersion() int

GetVersion returns the item version.

func (*MockDataItem) IsDeleted Uses

func (i *MockDataItem) IsDeleted() bool

IsDeleted returns true if this is a deleted item placeholder.

type MockOtherDataItem Uses

type MockOtherDataItem struct {
    Key     string
    Version int
    Deleted bool
}

MockDataItem is a test implementation of ld.VersionedData.

func (*MockOtherDataItem) GetKey Uses

func (i *MockOtherDataItem) GetKey() string

GetKey returns the item key.

func (*MockOtherDataItem) GetVersion Uses

func (i *MockOtherDataItem) GetVersion() int

GetVersion returns the item version.

func (*MockOtherDataItem) IsDeleted Uses

func (i *MockOtherDataItem) IsDeleted() bool

IsDeleted returns true if this is a deleted item placeholder.

Package ldtest imports 5 packages (graph). Updated 2020-03-18. Refresh now. Tools for package owners.