testutil

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteFailedTest

func ExecuteFailedTest(t *testing.T, parser TextParser, query string, expectedError error)

func ExecuteSuccessTest

func ExecuteSuccessTest(t *testing.T, parser TextParser, query string, expect bson.D)

func FindCompare

func FindCompare(t *testing.T, collection *mongo.Collection, filter interface{}, sort interface{}, items ...DummyDoc)

func NewClientWithCollection

func NewClientWithCollection(
	t *testing.T, mongoDB *strikememongo.Server,
) (*mongo.Client, *mongo.Collection, *mongo.Database)

NewClientWithCollection create a new mongo client for given strikemongo.

func NewStrikemongoServer

func NewStrikemongoServer(t *testing.T) *strikememongo.Server

NewStrikemongoServer creates a new strikemongo instance. Connection string can be obtained by `strikememongo.RandomDatabase()`. Keep in mind to stop the server after testing `defer mongoServer.Stop()`.

func Populate

func Populate(t *testing.T, collection *mongo.Collection, items []interface{})

Types

type DummyDoc

type DummyDoc struct {
	FirstName string `bson:"first_name"`
	LastName  string `bson:"last_name"`
	Gender    string `bson:"gender"`
	Age       int    `bson:"age"`
}

DummyDoc is a simple dummy doc for mongo tests.

type TextParser

type TextParser interface {
	Parse(query string) (bson.D, error)
}

Jump to

Keyboard shortcuts

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