testutil

package
v0.7.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 27, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package testutil contains testing utilities for storage providers and backends.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustBootstrap

func MustBootstrap(ctx context.Context, t *testing.T, provider storage.Provider)

MustBootstrap is a helper function that calls Bootstrap and fails the test if there is an error.

func TestConsensusStorageConformance

func TestConsensusStorageConformance(ctx context.Context, t *testing.T, raftStorage storage.ConsensusStorage)

TestConsensusStorageConformance tests that the ConsensusStorage interface is implemented correctly.

func TestDualStorageConformance

func TestDualStorageConformance(ctx context.Context, t *testing.T, dualStorage storage.DualStorage)

TestDualStorageConformance tests that the DualStorage interface is implemented correctly.

func TestMeshStorageConformance

func TestMeshStorageConformance(ctx context.Context, t *testing.T, meshStorage storage.MeshStorage)

TestMeshStorageConformance tests that the MeshStorage interface is implemented correctly.

func TestStorageProviderConformance

func TestStorageProviderConformance(ctx context.Context, t *testing.T, newProvider NewProviderFunc)

TestStorageProviderConformance tests that the storage provider conforms to the storage provider interface.

Types

type Condition

type Condition[T comparable] func(T) bool

Condition is a function that returns true if the condition is met.

type DropStorage

type DropStorage interface {
	// DropAll drops all data from the storage. This is primarily used
	// for testing.
	DropAll(ctx context.Context) error
}

DropStorage is a storage interface that can be dropped entirely. This is primarily used for testing.

type Eventually

type Eventually[T comparable] func() T

Eventually is a function that should eventually meet the given condition.

func (Eventually[T]) Should

func (e Eventually[T]) Should(t *testing.T, after time.Duration, tick time.Duration, condition func(T) bool) bool

Should eventually meet the given condition.

func (Eventually[T]) ShouldEqual

func (e Eventually[T]) ShouldEqual(t *testing.T, after time.Duration, tick time.Duration, expected T) bool

ShouldEqual eventually should equal the given value.

func (Eventually[T]) ShouldError

func (e Eventually[T]) ShouldError(t *testing.T, after time.Duration, tick time.Duration) bool

ShouldError eventually should error.

func (Eventually[T]) ShouldErrorWith

func (e Eventually[T]) ShouldErrorWith(t *testing.T, after time.Duration, tick time.Duration, expected error) bool

ShouldErrorWith eventually should error with the given error.

func (Eventually[T]) ShouldNotEqual

func (e Eventually[T]) ShouldNotEqual(t *testing.T, after time.Duration, tick time.Duration, expected T) bool

ShouldNotEqual eventually should not equal the given value.

func (Eventually[T]) ShouldNotError

func (e Eventually[T]) ShouldNotError(t *testing.T, after time.Duration, tick time.Duration) bool

ShouldNotError eventually should not error.

type NewProviderFunc

type NewProviderFunc func(ctx context.Context, t *testing.T) storage.Provider

NewProviderFunc is a function that returns a new started storage provider. It should have unique identifying properties for each call and not be bootstrapped.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL