Generic KVStore implementation tests

These are a set of common tests that should pass on any correct KVStore implementation.

Each test function in this package has the form:

func CommonTest<name>(t *testing.T, s store.KVStore) {...}

A KVStore implementation test should use the same name, including its own KVStore name in the test function. It should instantiate an instance of the store, and pass the testing.T and store to the common function.

The common test functions should NOT close the KVStore. The KVStore test implementation should close the store and cleanup any state.




This section is empty.


This section is empty.


func CommonTestKVCrud

func CommonTestKVCrud(t *testing.T, s store.KVStore)

func CommonTestMerge

func CommonTestMerge(t *testing.T, s store.KVStore)

func CommonTestPrefixIterator

func CommonTestPrefixIterator(t *testing.T, s store.KVStore)

func CommonTestPrefixIteratorSeek

func CommonTestPrefixIteratorSeek(t *testing.T, s store.KVStore)

func CommonTestRangeIterator

func CommonTestRangeIterator(t *testing.T, s store.KVStore)

func CommonTestRangeIteratorSeek

func CommonTestRangeIteratorSeek(t *testing.T, s store.KVStore)

func CommonTestReaderIsolation

func CommonTestReaderIsolation(t *testing.T, s store.KVStore)

func CommonTestReaderOwnsGetBytes

func CommonTestReaderOwnsGetBytes(t *testing.T, s store.KVStore)

    CommonTestReaderOwnsGetBytes attempts to mutate the returned bytes first, while the reader is still open, second after that reader is closed, then the original key is read again, to ensure these modifications did not cause panic, or mutate the stored value

    func CommonTestWriterOwnsBytes

    func CommonTestWriterOwnsBytes(t *testing.T, s store.KVStore)


    type TestMergeCounter

    type TestMergeCounter struct{}

      a test merge operator which is just an incrementing counter of uint64

      func (*TestMergeCounter) FullMerge

      func (mc *TestMergeCounter) FullMerge(key, existingValue []byte, operands [][]byte) ([]byte, bool)

      func (*TestMergeCounter) Name

      func (mc *TestMergeCounter) Name() string

      func (*TestMergeCounter) PartialMerge

      func (mc *TestMergeCounter) PartialMerge(key, leftOperand, rightOperand []byte) ([]byte, bool)