testutil

package
v2.3.6 Latest Latest
Warning

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

Go to latest
Published: May 27, 2016 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package testutil provides test utility functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AfterTest added in v2.3.0

func AfterTest(t *testing.T)

func CheckLeakedGoroutine added in v2.3.0

func CheckLeakedGoroutine() bool

CheckLeakedGoroutine verifies tests do not leave any leaky goroutines. It returns true when there are goroutines still running(leaking) after all tests.

import "github.com/coreos/etcd/pkg/testutil"

func TestMain(m *testing.M) {
	v := m.Run()
	if v == 0 && testutil.CheckLeakedGoroutine() {
		os.Exit(1)
	}
	os.Exit(v)
}

func TestSample(t *testing.T) {
	defer testutil.AfterTest(t)
	...
}

func FatalStack added in v2.3.0

func FatalStack(t *testing.T, s string)

FatalStack helps to fatal the test and print out the stacks of all running goroutines.

func MustNewURL

func MustNewURL(t *testing.T, s string) *url.URL

func MustNewURLs

func MustNewURLs(t *testing.T, urls []string) []url.URL

func WaitSchedule added in v2.1.0

func WaitSchedule()

TODO: improve this when we are able to know the schedule or status of target go-routine.

Types

type Action

type Action struct {
	Name   string
	Params []interface{}
}

type PauseableHandler

type PauseableHandler struct {
	Next http.Handler
	// contains filtered or unexported fields
}

func (*PauseableHandler) Pause

func (ph *PauseableHandler) Pause()

func (*PauseableHandler) Resume

func (ph *PauseableHandler) Resume()

func (*PauseableHandler) ServeHTTP

func (ph *PauseableHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Recorder

type Recorder interface {
	// Record publishes an Action (e.g., function call) which will
	// be reflected by Wait() or Chan()
	Record(a Action)
	// Wait waits until at least n Actions are available or returns with error
	Wait(n int) ([]Action, error)
	// Action returns immediately available Actions
	Action() []Action
	// Chan returns the channel for actions published by Record
	Chan() <-chan Action
}

func NewRecorderStream added in v2.3.0

func NewRecorderStream() Recorder

type RecorderBuffered added in v2.3.0

type RecorderBuffered struct {
	sync.Mutex
	// contains filtered or unexported fields
}

RecorderBuffered appends all Actions to a slice

func (*RecorderBuffered) Action added in v2.3.0

func (r *RecorderBuffered) Action() []Action

func (*RecorderBuffered) Chan added in v2.3.0

func (r *RecorderBuffered) Chan() <-chan Action

func (*RecorderBuffered) Record added in v2.3.0

func (r *RecorderBuffered) Record(a Action)

func (*RecorderBuffered) Wait added in v2.3.0

func (r *RecorderBuffered) Wait(n int) (acts []Action, err error)

Jump to

Keyboard shortcuts

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