cmdtest

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const OrderName = "cmdtest.TestingOrder"

OrderName is the name of all testing orders created by the cmdtest package.

Variables

View Source
var TestConfigjson = `` /* 231-byte string literal not displayed */

TestConfigjson data.

Functions

func NewTestOrder added in v0.0.3

func NewTestOrder() *dawg.Order

NewTestOrder creates an order for testing.

func TempDB

func TempDB() *cache.DataBase

TempDB will create a new database in the temp folder.

func TestAddress

func TestAddress() *obj.Address

TestAddress returns a testing address

Types

type Recorder

type Recorder struct {
	DataBase *cache.DataBase
	Conf     *cli.Config
	Out      *bytes.Buffer
	// contains filtered or unexported fields
}

Recorder is a mock command builder.

func NewRecorder

func NewRecorder() *Recorder

NewRecorder create a new command recorder.

func (*Recorder) Address

func (r *Recorder) Address() dawg.Address

Address returns the address.

func (*Recorder) Build

func (r *Recorder) Build(use, short string, run cli.Runner) *cli.Command

Build a command.

func (*Recorder) CleanUp

func (r *Recorder) CleanUp()

CleanUp will cleanup all the the Recorder tempfiles and free all resources.

func (*Recorder) Clear

func (r *Recorder) Clear() (err error)

Clear will clear all data stored by the recorder. This includes reseting the output buffer, opening a fresh database, and resetting the config.

func (*Recorder) ClearBuf

func (r *Recorder) ClearBuf()

ClearBuf will reset the internal output buffer.

func (*Recorder) Compare

func (r *Recorder) Compare(t *testing.T, expected string)

Compare the recorder output with a string

func (*Recorder) Config

func (r *Recorder) Config() *cli.Config

Config will return the config struct.

func (*Recorder) ConfigSetup

func (r *Recorder) ConfigSetup(b []byte) error

ConfigSetup will set the internal recorder config to be main struct used in the config package.

func (*Recorder) Contains

func (r *Recorder) Contains(s string) bool

Contains will return true if s is contained within the output buffer of the Recorder.

func (*Recorder) DB

func (r *Recorder) DB() *cache.DataBase

DB will return the internal database.

func (*Recorder) FreshDB

func (r *Recorder) FreshDB() error

FreshDB will close the old database, delete it, and open a fresh one.

func (*Recorder) GlobalOptions added in v0.0.3

func (r *Recorder) GlobalOptions() *opts.CliFlags

GlobalOptions has the global flags

func (*Recorder) Output

func (r *Recorder) Output() io.Writer

Output returns the reqorder's output.

func (*Recorder) StrEq

func (r *Recorder) StrEq(s string) bool

StrEq compares a string with the recorder output buffer.

func (*Recorder) ToApp

func (r *Recorder) ToApp() (*cache.DataBase, *cli.Config, io.Writer)

ToApp returns the arguments needed to create a cmd.App.

type TestRecorder added in v0.0.3

type TestRecorder struct {
	*Recorder
	// contains filtered or unexported fields
}

TestRecorder is a Recorder that has access to a testing.T

func NewTestRecorder added in v0.0.3

func NewTestRecorder(t *testing.T) *TestRecorder

NewTestRecorder creates a new TestRecorder

func (*TestRecorder) CleanUp added in v0.0.3

func (tr *TestRecorder) CleanUp()

CleanUp is a noop for go1.14

Jump to

Keyboard shortcuts

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