servicetest

package
v0.0.0-...-ff5f600 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2016 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Overview

Package servicetest provides functionality to help write tests for the Vanadium services.

Index

Constants

View Source
const (
	// TODO(caprita): Set the timeout in a more principled manner.
	ExpectTimeout = 20 * time.Second
)

Variables

This section is empty.

Functions

func CreateShell

func CreateShell(t *testing.T, ctx *context.T) (*v23test.Shell, func())

CreateShell builds a new shell. Returns the shell and a cleanup function.

func CreateShellAndMountTable

func CreateShellAndMountTable(t *testing.T, ctx *context.T) (*v23test.Shell, func())

CreateShellAndMountTable builds a new shell and starts a root mount table. Returns the shell and a cleanup function. TODO(sadovsky): Use v23test.StartRootMountTable.

func SetupRootDir

func SetupRootDir(t *testing.T, prefix string) (string, func())

SetupRootDir sets up and returns a directory for the root and returns a cleanup function.

Types

type Tape

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

Tape holds a record of function call stimuli and each function call's response. Use Tape to help build a mock framework by first creating a new Tape, then SetResponses to define the mock responses and then Record each function invocation. Play returns the function invocations for verification in a test.

func NewTape

func NewTape() *Tape

NewTape creates a new Tape.

func (*Tape) Play

func (t *Tape) Play() []interface{}

Play returns the function call stimuli recorded to this Tape.

func (*Tape) Record

func (t *Tape) Record(call interface{}) interface{}

Record stores a new function invocation in a Tape and returns the response for that function interface.

func (*Tape) Rewind

func (t *Tape) Rewind()

Rewind resets the tape to the beginning so that it could be used again for further tests.

func (*Tape) SetResponses

func (t *Tape) SetResponses(responses ...interface{})

SetResponses updates the Tape's associated responses.

type TapeMap

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

TapeMap provides multiple tapes for different strings. Use TapeMap to record separate Tapes for each suffix in a service.

func NewTapeMap

func NewTapeMap() *TapeMap

NewTapeMap creates a new empty TapeMap.

func (*TapeMap) ForSuffix

func (tm *TapeMap) ForSuffix(s string) *Tape

ForSuffix returns the Tape for suffix s.

func (*TapeMap) Rewind

func (tm *TapeMap) Rewind()

Rewind rewinds all of the Tapes in the TapeMap.

Jump to

Keyboard shortcuts

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