unified

package
v1.11.9 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2023 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEntityMapOpen = errors.New("slices cannot be accessed while EntityMap is open")

ErrEntityMapOpen is returned when a slice entity is accessed while the EntityMap is open

Functions

This section is empty.

Types

type EntityMap

type EntityMap struct {
	// contains filtered or unexported fields
}

EntityMap is used to store entities during tests. This type enforces uniqueness so no two entities can have the same ID, even if they are of different types. It also enforces referential integrity so construction of an entity that references another (e.g. a database entity references a client) will fail if the referenced entity does not exist. Accessors are available for the BSON entities.

func (*EntityMap) BSONArray

func (em *EntityMap) BSONArray(id string) ([]bson.Raw, error)

BSONArray returns the BSON document array associated with id. This should only be accessed after the test is finished running

func (*EntityMap) BSONValue

func (em *EntityMap) BSONValue(id string) (bson.RawValue, error)

BSONValue returns the bson.RawValue associated with id

func (*EntityMap) EventList

func (em *EntityMap) EventList(id string) ([]bson.Raw, error)

EventList returns the array of event documents associated with id. This should only be accessed after the test is finished running

func (*EntityMap) Iterations

func (em *EntityMap) Iterations(id string) (int32, error)

Iterations returns the number of iterations associated with id

func (*EntityMap) Successes

func (em *EntityMap) Successes(id string) (int32, error)

Successes returns the number of successes associated with id

type LoggerSkipper

type LoggerSkipper interface {
	Log(args ...interface{})
	Logf(format string, args ...interface{})
	Skip(args ...interface{})
	Skipf(format string, args ...interface{})
}

LoggerSkipper is passed to TestCase.Run to allow it to perform logging and skipping operations

type Options

type Options struct {
	// Specifies if killAllSessions should be run after the test completes.
	// Defaults to true
	RunKillAllSessions *bool
}

Options is the type used to configure tests

func MergeOptions

func MergeOptions(opts ...*Options) *Options

MergeOptions combines the given *Options into a single *Options in a last one wins fashion.

func NewOptions

func NewOptions() *Options

NewOptions creates an empty options interface

func (*Options) SetRunKillAllSessions

func (op *Options) SetRunKillAllSessions(killAllSessions bool) *Options

SetRunKillAllSessions sets the value for RunKillAllSessions

type ReadPreference added in v1.8.0

type ReadPreference struct {
	Mode                string              `bson:"mode"`
	TagSets             []map[string]string `bson:"tagSets"`
	MaxStalenessSeconds *int64              `bson:"maxStalenessSeconds"`
	Hedge               bson.M              `bson:"hedge"`
}

ReadPreference is a representation of BSON readPreference objects in tests.

func (*ReadPreference) ToReadPrefOption added in v1.8.0

func (rp *ReadPreference) ToReadPrefOption() (*readpref.ReadPref, error)

ToReadPrefOption converts a ReadPreference into a readpref.ReadPref object and will error if the original ReadPreference is malformed.

type TestCase

type TestCase struct {
	Description       string             `bson:"description"`
	RunOnRequirements []mtest.RunOnBlock `bson:"runOnRequirements"`
	SkipReason        *string            `bson:"skipReason"`
	Operations        []*operation       `bson:"operations"`
	ExpectedEvents    []*expectedEvents  `bson:"expectEvents"`
	Outcome           []*collectionData  `bson:"outcome"`
	// contains filtered or unexported fields
}

TestCase holds and runs a unified spec test case

func ParseTestFile

func ParseTestFile(t *testing.T, testJSON []byte, opts ...*Options) ([]mtest.RunOnBlock, []*TestCase)

ParseTestFile create an array of TestCases from the testJSON json blob

func (*TestCase) EndLoop

func (tc *TestCase) EndLoop()

EndLoop will cause the runner to stop a loop operation if one is included in the test. If the test has finished running, this will panic

func (*TestCase) GetEntities

func (tc *TestCase) GetEntities() *EntityMap

GetEntities returns a pointer to the EntityMap for the TestCase. This should not be called until after the test is run

func (*TestCase) Run

func (tc *TestCase) Run(ls LoggerSkipper) error

Run runs the TestCase and returns an error if it fails

type TestFile

type TestFile struct {
	Description       string                      `bson:"description"`
	SchemaVersion     string                      `bson:"schemaVersion"`
	RunOnRequirements []mtest.RunOnBlock          `bson:"runOnRequirements"`
	CreateEntities    []map[string]*entityOptions `bson:"createEntities"`
	InitialData       []*collectionData           `bson:"initialData"`
	TestCases         []*TestCase                 `bson:"tests"`
}

TestFile holds the contents of a unified spec test file

Jump to

Keyboard shortcuts

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