mongodb

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMongoDSN

func GetMongoDSN() string

GetMongoDSN returns DSN to connect to MongoDB

func New

func New(ctx context.Context, dsn string, name string, logger *zap.Logger) *mongo.Client

New creates new instance of the MongoDB client

Types

type TestDB

type TestDB struct {
	MongoClient *mongo.Client
	Database    mongostorage.StorageReaderWriter
}

TestDB defines db client and data access layers.

func NewTestDatabase

func NewTestDatabase(dsn, dbName string) (TestDB, error)

func (*TestDB) TruncateCollection

func (t *TestDB) TruncateCollection(collection string)

TruncateCollection will remove all documents from a given collection

type TestDBSuite

type TestDBSuite struct {
	suite.Suite
	DSN    string
	DBName string
	TestDB
}

TestDBSuite defines a suite that can be embedded into other test suites. This provides out of the box capability to plugin DB for test cases. The lifecycle of the DB client is governed by the engulfing suite itself.

func NewTestDBSuite

func NewTestDBSuite(database string) TestDBSuite

NewTestDBSuite creates new test suite for tests dependent on a database

func (*TestDBSuite) DropCollection

func (t *TestDBSuite) DropCollection(collection string)

DropCollection will drop the collection

func (*TestDBSuite) EnforceCollectionSchema

func (t *TestDBSuite) EnforceCollectionSchema(collectionName string, schemaPath string) error

func (*TestDBSuite) SetupSuite

func (t *TestDBSuite) SetupSuite()

SetupSuite sets up the test db suite.

func (*TestDBSuite) TruncateCollection

func (t *TestDBSuite) TruncateCollection(collection string)

TruncateCollection will remove all documents from a given collection

Jump to

Keyboard shortcuts

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