testing

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2015 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 added in v0.2.0

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

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

func CreateObjects added in v0.2.0

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 added in v0.2.0

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