testing

package
v0.0.0-...-b95dbb3 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2016 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupDB

func CleanupDB(t *DB) error

CleanupDB closes and removes the DB.

func CleanupObjects

func CleanupObjects(d db.DB, obs []util.Key)

CleanupObjects cleans the given map of IDs to Objects in the database.

func CreateObjects

func CreateObjects(d db.DB, obs map[util.Key]*object.Object)

CreateObjects stores the given map of IDs to Objects in the database.

Types

type DB

type DB struct {
	bolt.DB
	// contains filtered or unexported fields
}

DB fulfills db.DB with attributes that can be manually set.

func NewDB

func NewDB(setup ...SetupFunc) (*DB, error)

NewDB makes a new DB with the given setup func(s). Usage: import t "github.com/mf-proto/testing" db, err := t.NewDB(

t.SetupBolt("test.db"),
t.SetupBuckets("Admins", "Users"),

)

func (*DB) Update

func (t *DB) Update(fn func(*bolt.Tx) error) error

Update returns the pre-configured update error, or calls through to the underlying bolt DB.

func (*DB) View

func (t *DB) View(fn func(*bolt.Tx) error) error

View returns the pre-configured update error, or calls through to the underlying bolt DB.

type SetupFunc

type SetupFunc func(*DB) error

SetupFunc is a func which sets up a *DB.

func LoginUsers

func LoginUsers(d db.DB, users ...TestUser) SetupFunc

func SetupBolt

func SetupBolt(name string) SetupFunc

SetupBolt sets up a BoltDB testing DB with the given filename.

func SetupBuckets

func SetupBuckets(buckets ...[]db.Bucket) SetupFunc

SetupBuckets adds the given db.Buckets to the DB.

func SetupUpdateErr

func SetupUpdateErr(msg string, vals ...interface{}) SetupFunc

SetupUpdateErr adds an error to be returned when Update is called for the DB.

func SetupViewErr

func SetupViewErr(msg string, vals ...interface{}) SetupFunc

SetupViewErr adds an error to be returned when View is called for the DB.

type TestAdmin

type TestAdmin struct {
	Email  string
	Pwhash string
	Key    util.Key
}

type TestUser

type TestUser struct {
	Email     string
	Pwhash    string
	LoginKey  string
	LoginHash string
}

Jump to

Keyboard shortcuts

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