testutil

package
v0.0.0-...-7dca2ca Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2016 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MongoSuite

type MongoSuite struct {
	suite.Suite
	// contains filtered or unexported fields
}

MongoSuite is a testify Suite that adds functions to setup and teardown test Mongo DBs, as well as other provides functions for other common Mongo-related tasks such as inserting a fixture into the database.

func (*MongoSuite) DB

func (suite *MongoSuite) DB() *mgo.Database

DB returns a pointer to the suite's test Database, named "ie-test", initializing a new Database, Session, and/or DBServer if necessary. Subsequent calls will return the same Database until TearDownDB() is called. If a test suite calls DB(), then TearDownDBServer() MUST be called in the TearDownSuite function (or TearDownTest, if appropriate).

func (*MongoSuite) DBServer

func (suite *MongoSuite) DBServer() *dbtest.DBServer

DBServer returns a pointer to the suite's test Mongo DBServer, initializing a new one if necessary. Subsequent calls will return the same DBServer until TearDownDBServer is called. In most cases, calls to DBServer() are completely unnecessary, as calls to DB() will automatically instantiate the DBServer if needed. If a test suite calls DBServer(), then TearDownDBServer() MUST be called in the TearDownSuite function (or TearDownTest, if appropriate).

func (*MongoSuite) InsertFixture

func (suite *MongoSuite) InsertFixture(collection string, pathToFixture string, doc interface{})

InsertFixture inserts a test fixture into the Mongo database. If the fixture does not have an _id set, InsertFixture will attempt to find the _id field using reflection and will set it to a new BSON ID before inserting.

func (*MongoSuite) PrintDBServerInfo

func (suite *MongoSuite) PrintDBServerInfo()

PrintDBServerInfo logs out the connection info for the current test database.

func (*MongoSuite) TearDownDB

func (suite *MongoSuite) TearDownDB()

TearDownDB closes the suite's test Session and wipes the DBServer (thereby removing the Database). This function would typically be called in the test suite's TearDownTest function.

func (*MongoSuite) TearDownDBServer

func (suite *MongoSuite) TearDownDBServer()

TearDownDBServer cleans up the suite's test Mongo DBServer, including closing any open sessions, wiping the data, stopping the test DBServer, and deleting the temporary directory where the DBServer stored files. This function would typically be called in the test suite's TearDownSuite function.

Jump to

Keyboard shortcuts

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