...

Package unified

import "go.mongodb.org/mongo-driver/mongo/integration/unified"
Overview
Index

Overview ▾

Index ▾

Package files

admin_helpers.go bsonutil.go bucket_options.go bulkwrite_helpers.go client_encryption_operation_execution.go client_entity.go client_operation_execution.go collection_data.go collection_operation_execution.go common_options.go context.go crud_helpers.go cursor_entity.go cursor_operation_execution.go database_operation_execution.go db_collection_options.go entity.go error.go event.go event_verification.go gridfs_bucket_operation_execution.go logger.go logger_verification.go matches.go operation.go options.go result.go schema_version.go server_api_options.go session_operation_execution.go session_options.go testrunner_operation.go unified_spec_runner.go

Variables

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")
)

type EntityMap

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.

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

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

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

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

func (*Logger) Error

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

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

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

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

type Options

Options is the type used to configure tests

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

func MergeOptions

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

ReadPreference is a representation of BSON readPreference objects in tests.

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

func (*ReadPreference) ToReadPrefOption

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

TestCase holds and runs a unified spec test case

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
}

func ParseTestFile

func ParseTestFile(t *testing.T, testJSON []byte, expectValidFail bool, 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

TestFile holds the contents of a unified spec test file

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"`
}