testing

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2016 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ReadStdout func() string

ReadStdout value

View Source
var ResetStdout func()

ResetStdout back to os.Stdout

Functions

func BeforeOnce

func BeforeOnce(beforeBlock func())

BeforeOnce runs the before each block only once

func Delete

func Delete(app *api.App, url, body string) (int, string)

Delete from server

func Get

func Get(app *api.App, url string) (int, string)

Get from server

func GetBulkDonations

func GetBulkDonations(game *models.Game, clan string, donationRequestCount, donationsPerDonationRequest int, timestamp int64, db *mgo.Database, logger zap.Logger) ([]*models.Player, []*models.DonationRequest, error)

GetBulkDonations gets many donations and donation requests

func GetConfPath

func GetConfPath() string

GetConfPath returns teh configuration path

func GetDefaultTestApp

func GetDefaultTestApp(logger zap.Logger) *api.App

GetDefaultTestApp returns a new podium API Application bound to 0.0.0.0:8890 for test

func GetFirstItem

func GetFirstItem(g *models.Game) *models.Item

GetFirstItem In Game

func GetPerfMongoDB

func GetPerfMongoDB() (*mgo.Session, *mgo.Database)

GetPerfMongoDB returns a test connection to PERF mongo db

func GetRequest

func GetRequest(app *api.App, ts *httptest.Server, method, url string, bodyBuff io.Reader) *http.Request

GetRequest builds a new request for tests

func GetTestDonationRequest

func GetTestDonationRequest(game *models.Game, db *mgo.Database, logger zap.Logger) (*models.DonationRequest, error)

GetTestDonationRequest to use in tests

func GetTestGame

func GetTestGame(db *mgo.Database, logger zap.Logger, withItems bool, options ...map[string]interface{}) (*models.Game, error)

GetTestGame to use in tests

func GetTestMongoDB

func GetTestMongoDB() (*mgo.Session, *mgo.Database)

GetTestMongoDB returns a test connection to mongo db

func GetTestMutex

func GetTestMutex(name string, rs *redsync.Redsync) *redsync.Mutex

GetTestMutex returns a mutex for the name specified

func GetTestPlayer

func GetTestPlayer(game *models.Game, db *mgo.Database, logger zap.Logger) (*models.Player, error)

GetTestPlayer to use in tests

func GetTestRedis

func GetTestRedis() redis.Conn

GetTestRedis returns a configured redsync connection

func GetTestRedsync

func GetTestRedsync() *redsync.Redsync

GetTestRedsync returns a configured redsync connection

func InitializeTestServer

func InitializeTestServer(app *api.App) *httptest.Server

InitializeTestServer for tests

func MockStdout

func MockStdout()

MockStdout to read it's value later

func PerformRequest

func PerformRequest(ts *httptest.Server, req *http.Request) *http.Response

PerformRequest against specified test server

func Post

func Post(app *api.App, url, body string) (int, string)

Post to server

func Put

func Put(app *api.App, url, body string) (int, string)

Put to server

func ReadBody

func ReadBody(res *http.Response) []byte

ReadBody from response

func ToNullInt64

func ToNullInt64(v int64) sql.NullInt64

ToNullInt64 returns valid if int > 0

Types

type MockClock

type MockClock struct {
	Time int64
}

MockClock abstracts time

func (*MockClock) GetUTCTime

func (m *MockClock) GetUTCTime() time.Time

GetUTCTime returns the mocked time

type TestBuffer

type TestBuffer struct {
	bytes.Buffer
}

TestBuffer is a mock buffer

func (*TestBuffer) Lines

func (b *TestBuffer) Lines() []string

Lines returns all lines of log

func (*TestBuffer) Stripped

func (b *TestBuffer) Stripped() string

Stripped removes new lines

func (*TestBuffer) Sync

func (b *TestBuffer) Sync() error

Sync does nothing

Jump to

Keyboard shortcuts

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