testing

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2017 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package testing is an extension to the standard go testing package tailored for testing the lego framework.

This package should solely be used by test packages.

Index

Constants

View Source
const (
	// TC is the TRACE log constant
	TC = "TRACE"
	// WN is the WARNING log constant
	WN = "WARN"
	// ER is the ERROR log constant
	ER = "ERRR"
)
View Source
const (
	OpCount = iota
	OpInc
	OpDec
	OpGauge
	OpTiming
	OpHistogram
)

Variables

This section is empty.

Functions

func DidPanic

func DidPanic(f func()) (bool, interface{})

DidPanic returns whether the given function panicked

func NewLogger

func NewLogger(t *testing.T, strict bool) log.Logger

NewLogger creates a new logger

func NewStats

func NewStats(t *testing.T) stats.Stats

NewStats creates a new stats

func NextPort added in v1.3.0

func NextPort() int

NextPort returns the next supposedly available port number

Types

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger is a simple Logger interface useful for tests

func (*Logger) AddCalldepth

func (l *Logger) AddCalldepth(n int) log.Logger

func (*Logger) Error

func (l *Logger) Error(tag, msg string, fields ...log.Field)

func (*Logger) Lines

func (l *Logger) Lines(s string) int

Lines returns the number of log lines for the given severity

func (*Logger) Trace

func (l *Logger) Trace(tag, msg string, fields ...log.Field)

func (*Logger) Warning

func (l *Logger) Warning(tag, msg string, fields ...log.Field)

func (*Logger) With

func (l *Logger) With(fields ...log.Field) log.Logger

type Stats

type Stats struct {
	Data map[string][]StatsPoint
	// contains filtered or unexported fields
}

Stats is a simple Stats interface useful for tests

func (*Stats) Count

func (s *Stats) Count(key string, n interface{}, meta ...map[string]string)

func (*Stats) Dec

func (s *Stats) Dec(key string, meta ...map[string]string)

func (*Stats) Gauge

func (s *Stats) Gauge(key string, n interface{}, meta ...map[string]string)

func (*Stats) Histogram

func (s *Stats) Histogram(key string, n interface{}, meta ...map[string]string)

func (*Stats) Inc

func (s *Stats) Inc(key string, meta ...map[string]string)

func (*Stats) SetLogger

func (s *Stats) SetLogger(l log.Logger)

func (*Stats) Start

func (s *Stats) Start()

func (*Stats) Stop

func (s *Stats) Stop()

func (*Stats) Timing

func (s *Stats) Timing(key string, d time.Duration, meta ...map[string]string)

type StatsOp

type StatsOp int

StatsOp an operation, such as count, gauge, timing sent to the testing stats

type StatsPoint

type StatsPoint struct {
	Op   StatsOp
	N    interface{}
	Meta []map[string]string
}

type T

type T struct {
	// contains filtered or unexported fields
}

T is a wrapper of go standard testing.T It adds a few additional functions useful to lego

func New

func New(t *testing.T) *T

New returns a new instance of T

func (*T) Config

func (t *T) Config() *config.Config

Config returns an empty lego config

func (*T) DisableStrictMode added in v0.1.0

func (t *T) DisableStrictMode()

DisableStrictMode will stop making error logs failing a test

func (*T) Error

func (t *T) Error(args ...interface{})

Standard go testing.T functions

func (*T) Errorf

func (t *T) Errorf(format string, args ...interface{})

func (*T) Fail

func (t *T) Fail()

func (*T) FailNow

func (t *T) FailNow()

func (*T) Failed

func (t *T) Failed()

func (*T) Fatal

func (t *T) Fatal(args ...interface{})

func (*T) Fatalf

func (t *T) Fatalf(format string, args ...interface{})

func (*T) Log

func (t *T) Log(args ...interface{})

func (*T) Logf

func (t *T) Logf(format string, args ...interface{})

func (*T) Logger

func (t *T) Logger() log.Logger

Logger returns a lego logger interface

func (*T) NewAppCtx

func (t *T) NewAppCtx(name string) app.Ctx

Logger returns a lego logger interface

func (*T) Parallel

func (t *T) Parallel()

func (*T) Skip

func (t *T) Skip(args ...interface{})

func (*T) SkipNow

func (t *T) SkipNow()

func (*T) Skipf

func (t *T) Skipf(format string, args ...interface{})

func (*T) Skipped

func (t *T) Skipped()

func (*T) Stats

func (t *T) Stats() stats.Stats

Stats returns a lego stats interface

Jump to

Keyboard shortcuts

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