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



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


    This section is empty.


    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.


          type Tape

          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

            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 {
                      	// 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.