BigSegmentStoreTestSuite provides a configurable test suite for all implementations of BigSegmentStore.
type BigSegmentStoreTestSuite struct {
// contains filtered or unexported fields
}
func NewBigSegmentStoreTestSuite( storeFactoryFn func(prefix string) subsystems.ComponentConfigurer[subsystems.BigSegmentStore], clearDataFn func(prefix string) error, setMetadataFn func(prefix string, metadata subsystems.BigSegmentStoreMetadata) error, setSegmentsFn func(prefix string, userHashKey string, included []string, excluded []string) error, ) *BigSegmentStoreTestSuite
NewBigSegmentStoreTestSuite creates an BigSegmentStoreTestSuite for testing some implementation of BigSegmentStore.
The storeFactoryFn parameter is a function that takes a prefix string and returns a configured factory for this data store type (for instance, ldredis.DataStore().Prefix(prefix)). If the prefix string is "", it should use the default prefix defined by the data store implementation. The factory must include any necessary configuration that may be appropriate for the test environment (for instance, pointing it to a database instance that has been set up for the tests).
The clearDataFn parameter is a function that takes a prefix string and deletes any existing data that may exist in the database corresponding to that prefix.
The setMetadataFn and setSegmentsFn parameters are functions for populating the database. The string slices passed to setSegmentsFn are lists of segment references in the same format used by BigSegmentMembership, and should be used as-is by the store.
func (s *BigSegmentStoreTestSuite) Run(t *testing.T)
Run runs the configured test suite.
PersistentDataStoreTestSuite provides a configurable test suite for all implementations of PersistentDataStore.
In order to be testable with this tool, a data store implementation must have the following characteristics:
1. It has some notion of a "prefix" string that can be used to distinguish between different SDK instances using the same underlying database.
2. Two instances of the same data store type with the same configuration, and the same prefix, should be able to see each other's data.
type PersistentDataStoreTestSuite struct {
// contains filtered or unexported fields
}
func NewPersistentDataStoreTestSuite( storeFactoryFn func(prefix string) ssys.ComponentConfigurer[ssys.PersistentDataStore], clearDataFn func(prefix string) error, ) *PersistentDataStoreTestSuite
NewPersistentDataStoreTestSuite creates a PersistentDataStoreTestSuite for testing some implementation of PersistentDataStore.
The storeFactoryFn parameter is a function that takes a prefix string and returns a configured factory for this data store type (for instance, ldconsul.DataStore().Prefix(prefix)). If the prefix string is "", it should use the default prefix defined by the data store implementation. The factory must include any necessary configuration that may be appropriate for the test environment (for instance, pointing it to a database instance that has been set up for the tests).
The clearDataFn parameter is a function that takes a prefix string and deletes any existing data that may exist in the database corresponding to that prefix.
func (s *PersistentDataStoreTestSuite) ConcurrentModificationHook( setHookFn func(store ssys.PersistentDataStore, hook func()), ) *PersistentDataStoreTestSuite
ConcurrentModificationHook enables tests of concurrent modification behavior, for store implementations that support testing this.
The hook parameter is a function which, when called with a store instance and another function as parameters, will modify the store instance 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 (s *PersistentDataStoreTestSuite) ErrorStoreFactory( errorStoreFactory ssys.ComponentConfigurer[ssys.PersistentDataStore], errorValidator func(assert.TestingT, error), ) *PersistentDataStoreTestSuite
ErrorStoreFactory enables a test of error handling. The provided errorStoreFactory is expected to produce a data store instance whose operations should all fail and return an error. The errorValidator function, if any, will be called to verify that it is the expected error.
func (s *PersistentDataStoreTestSuite) Run(t *testing.T)
Run runs the configured test suite.