v.io: v.io/x/ref/services/internal/servicetest Index | Files

package servicetest

import "v.io/x/ref/services/internal/servicetest"

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


Package Files

doc.go mock.go modules.go timeouts.go


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

func CreateShell Uses

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 Uses

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 Uses

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

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

type Tape Uses

type Tape struct {
    // 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 Uses

func NewTape() *Tape

NewTape creates a new Tape.

func (*Tape) Play Uses

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

Play returns the function call stimuli recorded to this Tape.

func (*Tape) Record Uses

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 Uses

func (t *Tape) Rewind()

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

func (*Tape) SetResponses Uses

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

SetResponses updates the Tape's associated responses.

type TapeMap Uses

type TapeMap struct {
    // 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 Uses

func NewTapeMap() *TapeMap

NewTapeMap creates a new empty TapeMap.

func (*TapeMap) ForSuffix Uses

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

ForSuffix returns the Tape for suffix s.

func (*TapeMap) Rewind Uses

func (tm *TapeMap) Rewind()

Rewind rewinds all of the Tapes in the TapeMap.

Package servicetest imports 20 packages (graph) and is imported by 2 packages. Updated 2020-09-08. Refresh now. Tools for package owners.