testutil

package
v0.0.0-...-b3f3fbb Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2015 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package testutil provides utilities (decorators, helpers, assertions...) for testing

Index

Constants

View Source
const (
	// EnvVarMySQLTest is the environment var, which must be present to run
	// MySQL tests
	EnvVarMySQLTest = "PAYMENTD_MYSQLTEST"
	// EnvVarMySQLTestPaymentDSN holds the DSN for the test database for payment
	EnvVarMySQLTestPaymentDSN = "PAYMENTD_MYSQLTEST_PAYMENTDSN"
	// EnvVarMySQLTestPaymentDSN holds the DSN for the test database for payment
	EnvVarMySQLTestPrincipalDSN = "PAYMENTD_MYSQLTEST_PRINCIPALDSN"
)

Variables

This section is empty.

Functions

func ReportLog

func ReportLog(t *testing.T, logChan <-chan *log15.Record)

func WithContext

func WithContext(f func(*service.Context, <-chan *log15.Record)) func()

WithContext is a decorator for GoConvey based tests

It will inject a service context and a log channel, where log messages can be read from

func WithPaymentDB

func WithPaymentDB(t *testing.T, f func(db *sql.DB)) func()

WithPaymentDB is a test decorator providing a DB connection to the test payment DB

func WithPrincipalDB

func WithPrincipalDB(t *testing.T, f func(db *sql.DB)) func()

WithPrincipalDB is a test decorator providing a DB connection to the test principal DB

Types

type ResponseWriter

type ResponseWriter struct {
	Buf           bytes.Buffer
	H             http.Header
	HeaderWritten bool
	StatusCode    int
}

ResponseWriter is a mock http.ResponseWriter which can be used to inspect HTTP handler responses

func NewResponseWriter

func NewResponseWriter() *ResponseWriter

NewResponseWriter creates a response writer to capture http handler responses

func (*ResponseWriter) Header

func (r *ResponseWriter) Header() http.Header

Header implementing the http.ResponseWriter

func (*ResponseWriter) Write

func (r *ResponseWriter) Write(p []byte) (int, error)

Write implementing the http.ResponseWriter, io.Writer

func (*ResponseWriter) WriteHeader

func (r *ResponseWriter) WriteHeader(statusCode int)

WriteHeader implementing the http.ResponseWriter

Directories

Path Synopsis
Package payment provides test decorators for payment related tests
Package payment provides test decorators for payment related tests

Jump to

Keyboard shortcuts

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