Search and commands

↑ ↓ to select · Enter to open · Esc to close

Type to search packages.

testdb

v1.0.0
github.com/redforks/testing/mongo/testdb

Documentation

pkg.go.dev ↗

Table of contents

↓ to select · Enter to jump· Shift+Enter for source

4 matches

Top ↑

Types

TestDb

type TestDb struct {
	Session *mgo.Session
	*mgo.Database
	// contains filtered or unexported fields
}

TestDb create a connection to mongodb, and delete the database in reset. Also provide mongodb operation methods, so we do not need to deal with returned error. *mgo.Databae is nested in, so all Database method con be used directly from TestDb, such as:

db := testdb.New("blah_test")
db.C("tbl").Insert(...

Instead of:

db.Session.DB("").C("tbl").Insert(...

New

func New(dbUrl string) *TestDb

Create a new TestDb instance.

TestDb.Url

func (db *TestDb) Url() string

Return mongodb connection url

Dependency graph