subcommands: Index | Files

package subcommandstest

import ""

Includes tools to help with concurrent testing.


Package Files


func DisableLogOutput Uses

func DisableLogOutput() *bytes.Buffer

DisableLogOutput redirect log's default logger to a buffer and returns it. This function should be called in an init function.

func PrintIf Uses

func PrintIf(b []byte, name string)

PrintIf trims the whitespace around a string encoded as []byte and prints it only if not empty.

type Application Uses

type Application interface {
    GetLog() *log.Logger

Application supports all of subcommands.Application and adds GetLog() for testing purposes.

type ApplicationMock Uses

type ApplicationMock struct {

ApplicationMock wrap both an Application and a TB. ApplicationMock implements GetOut and GetErr and adds GetLog(). GetLog() is implemented by TB.

func MakeAppMock Uses

func MakeAppMock(t *testing.T, a subcommands.Application) *ApplicationMock

MakeAppMock returns an initialized ApplicationMock.

func (*ApplicationMock) GetErr Uses

func (a *ApplicationMock) GetErr() io.Writer

func (*ApplicationMock) GetOut Uses

func (a *ApplicationMock) GetOut() io.Writer

type TB Uses

type TB struct {
    // contains filtered or unexported fields

TB wraps a testing.T object and adds functionality specific to command_support.

BUG: testing.TB is now a thing, so this struct should likely be renamed to reduce confusion?

func MakeTB Uses

func MakeTB(t *testing.T) *TB

MakeTB returns a fully initialized TB instance.

func (*TB) CheckBuffer Uses

func (t *TB) CheckBuffer(out, err bool)

CheckBuffer asserts the content of os.Stdout and os.Stderr mocks.

func (*TB) CheckOut Uses

func (t *TB) CheckOut(expected string)

CheckOut asserts that what was printed out Application.GetOut() matches what is expected. TODO(maruel): It doesn't matches the use case where the match must be fuzzy, for example when non-deterministic data is included in the output.

func (*TB) GetLog Uses

func (t *TB) GetLog() *log.Logger

func (*TB) Verbose Uses

func (t *TB) Verbose()

Verbose sets the current context as verbose. It immediately prints out all logs generated for this specific test case up to now and redirects the log to os.Stderr so the following log is directly output to the console.

Package subcommandstest imports 9 packages (graph) and is imported by 2 packages. Updated 2016-11-28. Refresh now. Tools for package owners.