Documentation ¶
Overview ¶
Package drivertest provides a conformance test for implementations of driver.
Index ¶
Constants ¶
const KeyField = "_id"
Variables ¶
This section is empty.
Functions ¶
func MakeUniqueStringDeterministicForTesting ¶ added in v0.12.0
func MakeUniqueStringDeterministicForTesting(seed int64)
Call when running tests that will be replayed. Each seed value will result in UniqueString producing the same sequence of values.
func RunConformanceTests ¶
func RunConformanceTests(t *testing.T, newHarness HarnessMaker, ct CodecTester)
RunConformanceTests runs conformance tests for provider implementations of docstore.
Types ¶
type CodecTester ¶ added in v0.12.0
type CodecTester interface { UnsupportedTypes() []UnsupportedType NativeEncode(interface{}) (interface{}, error) NativeDecode(value, dest interface{}) error DocstoreEncode(interface{}) (interface{}, error) DocstoreDecode(value, dest interface{}) error }
CodecTester describes functions that encode and decode values using both the docstore codec for a provider, and that provider's own "native" codec.
type Harness ¶
type Harness interface { // MakeCollection makes a driver.Collection for testing. MakeCollection(context.Context) (driver.Collection, error) // Close closes resources used by the harness. Close() }
Harness descibes the functionality test harnesses must provide to run conformance tests.
type HarnessMaker ¶
HarnessMaker describes functions that construct a harness for running tests. It is called exactly once per test; Harness.Close() will be called when the test is complete.
type UnsupportedType ¶ added in v0.12.0
type UnsupportedType int
Enum of types not supported by native codecs. We chose to describe this negatively (types that aren't supported rather than types that are) to make the more inclusive cases easier to write. A driver can return nil for CodecTester.UnsupportedTypes, then add values from this enum one by one until all tests pass.
const ( // Native codec doesn't support any unsigned integer type Uint UnsupportedType = iota // Native codec doesn't support any complex type Complex // Native codec doesn't support arrays Arrays )