mock_mongodb

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

README

db/mongodb/mocks

Import path: github.com/InsideGallery/core/db/mongodb/mocks

Package mock_mongodb contains generated GoMock test doubles for the legacy mongodb.Client interface. It is generated from db/mongodb/interface.go and is not a production API.

Main APIs

  • NewMockClient(ctrl) creates a generated mock client.
  • MockClient.EXPECT() returns the recorder used to set expected calls.
  • The generated mock covers methods from mongodb.Client, including find, aggregate, insert, update, delete, collection, database, connection, and batch update methods.

Usage

package example_test

import (
	"context"
	"testing"

	"github.com/InsideGallery/core/db/mongodb/mocks"
	"github.com/golang/mock/gomock"
)

func TestClient(t *testing.T) {
	ctrl := gomock.NewController(t)
	client := mock_mongodb.NewMockClient(ctrl)

	client.EXPECT().
		FindOne(context.Background(), "profiles", gomock.Any(), gomock.Any()).
		Return(nil)

	if err := client.FindOne(context.Background(), "profiles", map[string]any{}, map[string]any{}); err != nil {
		t.Fatal(err)
	}
}

Operational Notes

Do not import this package from production code. Regenerate it through the go:generate directive in db/mongodb/interface.go when the legacy interface changes.

Documentation

Overview

Package mock_mongodb is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockClient

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

MockClient is a mock of Client interface.

func NewMockClient

func NewMockClient(ctrl *gomock.Controller) *MockClient

NewMockClient creates a new mock instance.

func (*MockClient) Aggregate

func (m *MockClient) Aggregate(ctx context.Context, collection string, value, pipeline interface{}, opts ...*options.AggregateOptions) ([]interface{}, error)

Aggregate mocks base method.

func (*MockClient) BatchUpdateByID

func (m *MockClient) BatchUpdateByID(ctx context.Context, collection string, data map[interface{}]interface{}) error

BatchUpdateByID mocks base method.

func (*MockClient) Collection

func (m *MockClient) Collection(name string, opts ...*options.CollectionOptions) *mongo.Collection

Collection mocks base method.

func (*MockClient) Connection

func (m *MockClient) Connection() *mongo.Client

Connection mocks base method.

func (*MockClient) CountDocuments

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

CountDocuments mocks base method.

func (*MockClient) Database

func (m *MockClient) Database(name string, opts ...*options.DatabaseOptions) *mongo.Database

Database mocks base method.

func (*MockClient) DeleteCollection

func (m *MockClient) DeleteCollection(ctx context.Context, name string) error

DeleteCollection mocks base method.

func (*MockClient) DeleteMany

func (m *MockClient) DeleteMany(ctx context.Context, collection string, filter interface{}, opts ...*options.DeleteOptions) error

DeleteMany mocks base method.

func (*MockClient) DeleteOne

func (m *MockClient) DeleteOne(ctx context.Context, collection string, filter interface{}, opts ...*options.DeleteOptions) error

DeleteOne mocks base method.

func (*MockClient) Drop

func (m *MockClient) Drop(ctx context.Context, collection string) error

Drop mocks base method.

func (*MockClient) EXPECT

func (m *MockClient) EXPECT() *MockClientMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockClient) Find

func (m *MockClient) Find(ctx context.Context, collection string, value, filter interface{}, opts ...*options.FindOptions) ([]interface{}, error)

Find mocks base method.

func (*MockClient) FindOne

func (m *MockClient) FindOne(ctx context.Context, collection string, value, filter interface{}, opts ...*options.FindOneOptions) error

FindOne mocks base method.

func (*MockClient) FindOneByID

func (m *MockClient) FindOneByID(ctx context.Context, collection string, value, id interface{}, opts ...*options.FindOneOptions) error

FindOneByID mocks base method.

func (*MockClient) InsertMany

func (m *MockClient) InsertMany(ctx context.Context, collection string, documents []interface{}, opts ...*options.InsertManyOptions) error

InsertMany mocks base method.

func (*MockClient) InsertOne

func (m *MockClient) InsertOne(ctx context.Context, collection string, value interface{}, opts ...*options.InsertOneOptions) error

InsertOne mocks base method.

func (*MockClient) UpdateByObject

func (m *MockClient) UpdateByObject(ctx context.Context, collection string, value, filter interface{}, opts ...*options.UpdateOptions) error

UpdateByObject mocks base method.

func (*MockClient) UpsertMany

func (m *MockClient) UpsertMany(ctx context.Context, collection string, keys, documents []interface{}) error

UpsertMany mocks base method.

func (*MockClient) UpsertManyByFilter

func (m *MockClient) UpsertManyByFilter(ctx context.Context, collection, filterBy string, keys, documents []interface{}) error

UpsertManyByFilter mocks base method.

func (*MockClient) UpsertOne

func (m *MockClient) UpsertOne(ctx context.Context, collection string, update, filter interface{}, opts ...*options.UpdateOptions) error

UpsertOne mocks base method.

func (*MockClient) WithDB

func (m *MockClient) WithDB(name string) mongodb.Client

WithDB mocks base method.

type MockClientMockRecorder

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

MockClientMockRecorder is the mock recorder for MockClient.

func (*MockClientMockRecorder) Aggregate

func (mr *MockClientMockRecorder) Aggregate(ctx, collection, value, pipeline interface{}, opts ...interface{}) *gomock.Call

Aggregate indicates an expected call of Aggregate.

func (*MockClientMockRecorder) BatchUpdateByID

func (mr *MockClientMockRecorder) BatchUpdateByID(ctx, collection, data interface{}) *gomock.Call

BatchUpdateByID indicates an expected call of BatchUpdateByID.

func (*MockClientMockRecorder) Collection

func (mr *MockClientMockRecorder) Collection(name interface{}, opts ...interface{}) *gomock.Call

Collection indicates an expected call of Collection.

func (*MockClientMockRecorder) Connection

func (mr *MockClientMockRecorder) Connection() *gomock.Call

Connection indicates an expected call of Connection.

func (*MockClientMockRecorder) CountDocuments

func (mr *MockClientMockRecorder) CountDocuments(ctx, collection, filter interface{}, opts ...interface{}) *gomock.Call

CountDocuments indicates an expected call of CountDocuments.

func (*MockClientMockRecorder) Database

func (mr *MockClientMockRecorder) Database(name interface{}, opts ...interface{}) *gomock.Call

Database indicates an expected call of Database.

func (*MockClientMockRecorder) DeleteCollection

func (mr *MockClientMockRecorder) DeleteCollection(ctx, name interface{}) *gomock.Call

DeleteCollection indicates an expected call of DeleteCollection.

func (*MockClientMockRecorder) DeleteMany

func (mr *MockClientMockRecorder) DeleteMany(ctx, collection, filter interface{}, opts ...interface{}) *gomock.Call

DeleteMany indicates an expected call of DeleteMany.

func (*MockClientMockRecorder) DeleteOne

func (mr *MockClientMockRecorder) DeleteOne(ctx, collection, filter interface{}, opts ...interface{}) *gomock.Call

DeleteOne indicates an expected call of DeleteOne.

func (*MockClientMockRecorder) Drop

func (mr *MockClientMockRecorder) Drop(ctx, collection interface{}) *gomock.Call

Drop indicates an expected call of Drop.

func (*MockClientMockRecorder) Find

func (mr *MockClientMockRecorder) Find(ctx, collection, value, filter interface{}, opts ...interface{}) *gomock.Call

Find indicates an expected call of Find.

func (*MockClientMockRecorder) FindOne

func (mr *MockClientMockRecorder) FindOne(ctx, collection, value, filter interface{}, opts ...interface{}) *gomock.Call

FindOne indicates an expected call of FindOne.

func (*MockClientMockRecorder) FindOneByID

func (mr *MockClientMockRecorder) FindOneByID(ctx, collection, value, id interface{}, opts ...interface{}) *gomock.Call

FindOneByID indicates an expected call of FindOneByID.

func (*MockClientMockRecorder) InsertMany

func (mr *MockClientMockRecorder) InsertMany(ctx, collection, documents interface{}, opts ...interface{}) *gomock.Call

InsertMany indicates an expected call of InsertMany.

func (*MockClientMockRecorder) InsertOne

func (mr *MockClientMockRecorder) InsertOne(ctx, collection, value interface{}, opts ...interface{}) *gomock.Call

InsertOne indicates an expected call of InsertOne.

func (*MockClientMockRecorder) UpdateByObject

func (mr *MockClientMockRecorder) UpdateByObject(ctx, collection, value, filter interface{}, opts ...interface{}) *gomock.Call

UpdateByObject indicates an expected call of UpdateByObject.

func (*MockClientMockRecorder) UpsertMany

func (mr *MockClientMockRecorder) UpsertMany(ctx, collection, keys, documents interface{}) *gomock.Call

UpsertMany indicates an expected call of UpsertMany.

func (*MockClientMockRecorder) UpsertManyByFilter

func (mr *MockClientMockRecorder) UpsertManyByFilter(ctx, collection, filterBy, keys, documents interface{}) *gomock.Call

UpsertManyByFilter indicates an expected call of UpsertManyByFilter.

func (*MockClientMockRecorder) UpsertOne

func (mr *MockClientMockRecorder) UpsertOne(ctx, collection, update, filter interface{}, opts ...interface{}) *gomock.Call

UpsertOne indicates an expected call of UpsertOne.

func (*MockClientMockRecorder) WithDB

func (mr *MockClientMockRecorder) WithDB(name interface{}) *gomock.Call

WithDB indicates an expected call of WithDB.

Jump to

Keyboard shortcuts

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