testing

package
v2.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MockWriteException = mongo.WriteException{
	WriteErrors: mongo.WriteErrors{
		mongo.WriteError{
			Code: 11000,
		},
	},
}

Functions

func MockCursor

func MockCursor(objs ...interface{}) (*mongo.Cursor, error)

func MockSingleResult

func MockSingleResult(obj interface{}) (*mongo.SingleResult, error)

Types

type MockCollection

type MockCollection struct {
	CountDocumentsFn func(
		ctx context.Context,
		filter interface{},
		opts ...*options.CountOptions,
	) (int64, error)

	DeleteManyFn func(
		ctx context.Context,
		filter interface{},
		opts ...*options.DeleteOptions,
	) (*mongo.DeleteResult, error)

	DeleteOneFn func(
		ctx context.Context,
		filter interface{},
		opts ...*options.DeleteOptions,
	) (*mongo.DeleteResult, error)

	FindFn func(
		ctx context.Context,
		filter interface{},
		opts ...*options.FindOptions,
	) (*mongo.Cursor, error)

	FindOneFn func(
		ctx context.Context,
		filter interface{},
		opts ...*options.FindOneOptions,
	) *mongo.SingleResult

	FindOneAndReplaceFn func(
		ctx context.Context,
		filter interface{},
		replacement interface{},
		opts ...*options.FindOneAndReplaceOptions,
	) *mongo.SingleResult

	InsertOneFn func(
		ctx context.Context,
		document interface{},
		opts ...*options.InsertOneOptions,
	) (*mongo.InsertOneResult, error)

	UpdateManyFn func(
		ctx context.Context,
		filter interface{},
		update interface{},
		opts ...*options.UpdateOptions,
	) (*mongo.UpdateResult, error)

	UpdateOneFn func(
		ctx context.Context,
		filter interface{},
		update interface{},
		opts ...*options.UpdateOptions,
	) (*mongo.UpdateResult, error)
}

func (*MockCollection) CountDocuments

func (m *MockCollection) CountDocuments(
	ctx context.Context,
	filter interface{},
	opts ...*options.CountOptions,
) (int64, error)

func (*MockCollection) DeleteMany

func (m *MockCollection) DeleteMany(
	ctx context.Context,
	filter interface{},
	opts ...*options.DeleteOptions,
) (*mongo.DeleteResult, error)

func (*MockCollection) DeleteOne

func (m *MockCollection) DeleteOne(
	ctx context.Context,
	filter interface{},
	opts ...*options.DeleteOptions,
) (*mongo.DeleteResult, error)

func (*MockCollection) Find

func (m *MockCollection) Find(
	ctx context.Context,
	filter interface{},
	opts ...*options.FindOptions,
) (*mongo.Cursor, error)

func (*MockCollection) FindOne

func (m *MockCollection) FindOne(
	ctx context.Context,
	filter interface{},
	opts ...*options.FindOneOptions,
) *mongo.SingleResult

func (*MockCollection) FindOneAndReplace

func (m *MockCollection) FindOneAndReplace(
	ctx context.Context,
	filter interface{},
	replacement interface{},
	opts ...*options.FindOneAndReplaceOptions,
) *mongo.SingleResult

func (*MockCollection) InsertOne

func (m *MockCollection) InsertOne(
	ctx context.Context,
	document interface{},
	opts ...*options.InsertOneOptions,
) (*mongo.InsertOneResult, error)

func (*MockCollection) UpdateMany

func (m *MockCollection) UpdateMany(
	ctx context.Context,
	filter interface{},
	update interface{},
	opts ...*options.UpdateOptions,
) (*mongo.UpdateResult, error)

func (*MockCollection) UpdateOne

func (m *MockCollection) UpdateOne(
	ctx context.Context,
	filter interface{},
	update interface{},
	opts ...*options.UpdateOptions,
) (*mongo.UpdateResult, error)

Jump to

Keyboard shortcuts

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