fakeui

package
v0.44.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FakeIO

type FakeIO struct {
	In             *FakeReader
	Out            *FakeWriter
	StdIn          *os.File
	StdOut         *os.File
	PromptIn       *FakeReader
	PromptOut      *FakeWriter
	PasswordReader *FakeReader
	PromptErr      error
}

FakeIO is a helper type for testing that implements the ui.IO interface

func NewIO

func NewIO(t *testing.T) *FakeIO

NewIO creates a new FakeIO with empty buffers.

func (*FakeIO) Input

func (f *FakeIO) Input() io.Reader

Stdin returns the mocked In.

func (*FakeIO) IsInputPiped

func (f *FakeIO) IsInputPiped() bool

func (*FakeIO) IsOutputPiped

func (f *FakeIO) IsOutputPiped() bool

func (*FakeIO) Output

func (f *FakeIO) Output() io.Writer

Stdout returns the mocked Out.

func (*FakeIO) Prompts

func (f *FakeIO) Prompts() (io.Reader, io.Writer, error)

Prompts returns the mocked prompts and error.

func (*FakeIO) ReadSecret

func (f *FakeIO) ReadSecret() ([]byte, error)

func (*FakeIO) ReadStdout

func (f *FakeIO) ReadStdout() ([]byte, error)

func (*FakeIO) Stdin

func (f *FakeIO) Stdin() *os.File

func (*FakeIO) Stdout

func (f *FakeIO) Stdout() *os.File

type FakeReader

type FakeReader struct {
	*bytes.Buffer
	Piped bool

	Reads   []string
	ReadErr error
	// contains filtered or unexported fields
}

FakeReader implements the Reader interface.

func (*FakeReader) Read

func (f *FakeReader) Read(p []byte) (n int, err error)

Read returns the mocked ReadErr or reads from the mocked buffer.

type FakeWriter

type FakeWriter struct {
	*bytes.Buffer
	Piped bool
}

FakeWriter implements the Writer interface.

Jump to

Keyboard shortcuts

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