unified

package
v1.12.0-cloud2 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2024 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEntityMapOpen is returned when a slice entity is accessed while the EntityMap is open
	ErrEntityMapOpen = errors.New("slices cannot be accessed while 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 Logger added in v1.12.0

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

Logger is the Sink used to captured log messages for logger verification in the unified spec tests.

func (*Logger) Error added in v1.12.0

func (log *Logger) Error(err error, msg string, args ...interface{})

Error implements the logger.Sink interface's "Error" method for printing log errors. In this case, if an error occurs we will simply treat it as informational.

func (*Logger) Info added in v1.12.0

func (log *Logger) Info(level int, msg string, args ...interface{})

Info implements the logger.Sink interface's "Info" method for printing log messages.

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 deprecated

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

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

Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create a single options struct instead.

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"`
	ExpectLogMessages []*clientLogMessages `bson:"expectLogMessages"`
	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