integration

package module
v0.0.0-...-60220be Latest Latest
Warning

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

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

Documentation

Overview

Package integration provides FerretDB integration tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertEqualAltCommandError

func AssertEqualAltCommandError(t testtb.TB, expected mongo.CommandError, altMessage string, actual error) bool

AssertEqualAltCommandError asserts that the expected MongoDB error is the same as the actual (ignoring the Raw part); the alternative error message may be provided if FerretDB is unable to produce exactly the same text as MongoDB.

In general, error messages should be the same. Exceptions include:

  • MongoDB typos (e.g. "sortto" instead of "sort to");
  • MongoDB values formatting (e.g. we don't want to write additional code to format `{ $slice: { a: { b: 3 }, b: "string" } }` exactly the same way).

In any case, the alternative error message returned by FerretDB should not mislead users.

func AssertEqualAltWriteError

func AssertEqualAltWriteError(t testtb.TB, expected mongo.WriteError, altMessage string, actual error) bool

AssertEqualAltWriteError asserts that the expected MongoDB error is the same as the actual; the alternative error message may be provided if FerretDB is unable to produce exactly the same text as MongoDB.

func AssertEqualCommandError

func AssertEqualCommandError(t testtb.TB, expected mongo.CommandError, actual error) bool

AssertEqualCommandError asserts that the expected error is the same as the actual (ignoring the Raw part).

func AssertEqualDocuments

func AssertEqualDocuments(t testtb.TB, expected, actual bson.D) bool

AssertEqualDocuments asserts that two documents are equal in a way that is useful for tests (NaNs are equal, etc).

See testutil.AssertEqual for details.

func AssertEqualDocumentsSlice

func AssertEqualDocumentsSlice(t testtb.TB, expected, actual []bson.D) bool

AssertEqualDocumentsSlice asserts that two document slices are equal in a way that is useful for tests (NaNs are equal, etc).

See testutil.AssertEqual for details.

func AssertEqualWriteError

func AssertEqualWriteError(t testtb.TB, expected mongo.WriteError, actual error) bool

AssertEqualWriteError asserts that actual is a WriteException containing exactly one expected error (ignoring the Raw part).

func AssertMatchesBulkException

func AssertMatchesBulkException(t testtb.TB, expected, actual error)

AssertMatchesBulkException asserts that both errors are BulkWriteExceptions containing the same number of WriteErrors, and those WriteErrors are equal, except messages (and ignoring the Raw part).

TODO https://github.com/FerretDB/FerretDB/issues/3290

func AssertMatchesCommandError

func AssertMatchesCommandError(t testtb.TB, expected, actual error)

AssertMatchesCommandError asserts that both errors are equal CommandErrors, except messages (and ignoring the Raw part).

func AssertMatchesError

func AssertMatchesError(t testtb.TB, expected, actual error)

AssertMatchesError asserts that both errors are of same type and are equal in value, except the message and Raw part.

func AssertMatchesWriteError

func AssertMatchesWriteError(t testtb.TB, expected, actual error)

AssertMatchesWriteError asserts that both errors are WriteExceptions containing exactly one WriteError, and those WriteErrors are equal, except messages (and ignoring the Raw part).

func CollectIDs

func CollectIDs(t testtb.TB, docs []bson.D) []any

CollectIDs returns all _id values from given documents.

The order is preserved.

func CollectKeys

func CollectKeys(t testtb.TB, doc bson.D) []string

CollectKeys returns document keys.

The order is preserved.

func ConvertDocument

func ConvertDocument(t testtb.TB, doc bson.D) *types.Document

ConvertDocument converts given driver's document to FerretDB's *types.Document.

func ConvertDocuments

func ConvertDocuments(t testtb.TB, docs []bson.D) []*types.Document

ConvertDocuments converts given driver's documents slice to FerretDB's []*types.Document.

func FetchAll

func FetchAll(t testtb.TB, ctx context.Context, cursor *mongo.Cursor) []bson.D

FetchAll fetches all documents from the cursor, closing it.

func FilterAll

func FilterAll(t testtb.TB, ctx context.Context, collection *mongo.Collection, filter bson.D) []bson.D

FilterAll returns filtered documented from the given collection sorted by _id.

func FindAll

func FindAll(t testtb.TB, ctx context.Context, collection *mongo.Collection) []bson.D

FindAll returns all documents from the given collection sorted by _id.

func GenerateDocuments

func GenerateDocuments(startID, endID int32) (bson.A, []bson.D)

GenerateDocuments generates documents with _id ranging from startID to endID. It returns bson.A and []bson.D both containing same bson.D documents.

func UnsetRaw

func UnsetRaw(t testtb.TB, err error) error

UnsetRaw returns error with all Raw fields unset. It returns nil if err is nil.

Error is checked using a regular type assertion; wrapped errors (errors.As) are not checked.

Types

This section is empty.

Directories

Path Synopsis
Package cursors contains tests for cursors, tailable cursors, `getMore` command, etc.
Package cursors contains tests for cursors, tailable cursors, `getMore` command, etc.
Package setup provides integration tests setup helpers.
Package setup provides integration tests setup helpers.
Package shareddata provides data for tests and benchmarks.
Package shareddata provides data for tests and benchmarks.

Jump to

Keyboard shortcuts

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