cmdtest

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package cmdtest provides test utilities for testing commands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FakeCmdIO

type FakeCmdIO struct {
	StdIO  *FakeStdioReaderWriter
	FileIO *testutil.FakeFileReaderWriter
	ExitIO *FakeExiter
}

FakeCmdIO contains fake implementations of the CmdIo dependencies

func NewFakeCmdIO

func NewFakeCmdIO() *FakeCmdIO

NewFakeCmdIO creates a new FakeCmdIO

type FakeExiter

type FakeExiter struct {
	// Message is the exit message
	Message string
}

FakeExiter doesn't exit, but instead stores the exit message

func (*FakeExiter) Exit

func (e *FakeExiter) Exit(args ...interface{})

Exit stores the exit message

func (*FakeExiter) Exitf

func (e *FakeExiter) Exitf(format string, v ...interface{})

Exitf stores the exit message

type FakeStdioReaderWriter

type FakeStdioReaderWriter struct {
	// ReadBytes contains the bytes to be read.
	ReadBytes []byte

	// ReadErr is an error that occurs during Read. If ReadErr is present, then
	// ReadErr will be returned instead of ReadBytes
	ReadErr error

	// WriteBytes contains a record of the most-recently written bytes.
	WriteBytes []byte

	// WriteErr is an error that occurs during Write. If WriteErr is present, then
	// Write will write not write content and return WriteErr instead.
	WriteErr error
}

FakeStdioReaderWriter is a fake implementation of a reader/writer to stdout.

func (*FakeStdioReaderWriter) ReadAll

func (f *FakeStdioReaderWriter) ReadAll() ([]byte, error)

ReadAll returns all the ReadBytes or returns an error.

func (*FakeStdioReaderWriter) Write

func (f *FakeStdioReaderWriter) Write(b []byte) (int, error)

Write stores all the WriteBytes or returns an error.

Jump to

Keyboard shortcuts

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