gentest

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEBUG string = "DEBU"
	INFO         = "INFO"
	WARN         = "WARN"
	ERROR        = "ERRO"
	FATAL        = "FATA"
	PANIC        = "PANI"
	PRINT        = "PRIN"
)

Variables

This section is empty.

Functions

func CompareBox

func CompareBox(exp packd.Walkable, res genny.Results) error

CompareBox compares a packd.Walkable box of files (usually fixtures) the results of a genny.Runner

func CompareBoxStripped

func CompareBoxStripped(exp packd.Walkable, res genny.Results) error

CompareBoxStripped compares a packd.Walkable box of files (usually fixtures) the results of a genny.Runner by removing any whitespaces, tabs, or newlines.

func CompareCommands

func CompareCommands(exp []string, act []*exec.Cmd) error

CompareCommands asserts that the expected commands match the actual commands executed. The expected commands should be the commands, with arguments, as you would type them on the command line. In typical usage, the actual commands can be extracted from a genny#Generator.Results under the Commands key

func CompareFiles

func CompareFiles(exp []string, act []genny.File) error

CompareFiles compares a slice of expected filenames to a slice of genny.Files. Expected files can be listed in any order. An excellent choice for the actual files can be found in genny#Generator.Results under the Files attribute

func NewRunner

func NewRunner() *genny.Runner

NewRunner is a dry runner with gentest.NewLogger()

func Run

func Run(g *genny.Generator) (genny.Results, error)

Run executes the generator and returns results or an error

func RunGroup

func RunGroup(gg *genny.Group) (genny.Results, error)

RunGroup runs the group and returns results or an error

func RunNew

func RunNew(g *genny.Generator, err error) (genny.Results, error)

RunNew executes the generator and returns results or an error

Types

type Logger

type Logger struct {
	// Stream contains the raw byte stream from all logging activity. This is
	// useful for output with testing.(*T).Log in concert with checking for
	// testing.Verbose()
	Stream *bytes.Buffer

	// Log contains all log messages, categorized by log level. The keys of this
	// map are the log levels found in the const definitions.
	Log map[string][]string

	// PrintFn is an optional func which will be invoked with all log messages
	// when they are emitted
	PrintFn func(...interface{})

	// CloseFn is an optional cleanup function invoked at the end of the runner's
	// execution
	CloseFn func() error
	// contains filtered or unexported fields
}

Logger is a repository of log messages emitted by Generators suitable for examination in tests.

func NewLogger

func NewLogger() *Logger

NewLogger produces an initialized Logger

func (*Logger) Close

func (l *Logger) Close() error

Close is invoked at the end of a genny#Runner's execution. It will invoke a CloseFn if set.

func (*Logger) Debug

func (l *Logger) Debug(args ...interface{})

Debug combines a variadic number of strings into a single debug log message

func (*Logger) Debugf

func (l *Logger) Debugf(s string, args ...interface{})

Debugf processes a format string and produces a debug message to the test logger

func (*Logger) Error

func (l *Logger) Error(args ...interface{})

Error logs a message formed by combining the arguments into a single string at the Error level

func (*Logger) Errorf

func (l *Logger) Errorf(s string, args ...interface{})

Errorf logs the provided string at the warning level. Prior to logging, the string is processed as a format string against the provided arguments

func (*Logger) Fatal

func (l *Logger) Fatal(args ...interface{})

Fatal logs a message formed by combining the arguments into a single string at the Fatal level

func (*Logger) Fatalf

func (l *Logger) Fatalf(s string, args ...interface{})

Fatalf logs the provided string at the Fatal level. Prior to logging, the string is processed as a format string against the provided arguments

func (*Logger) Info

func (l *Logger) Info(args ...interface{})

Info combines a variadic number of strings into a log message at the Info level.

func (*Logger) Infof

func (l *Logger) Infof(s string, args ...interface{})

Infof processes a format string and produces a log message at the Info level

func (*Logger) Panic

func (l *Logger) Panic(args ...interface{})

Panic logs a message formed by combining the arguments into a single string at the Panic level

func (*Logger) Panicf

func (l *Logger) Panicf(s string, args ...interface{})

Panicf logs the provided string at the Panic level. Prior to logging, the string is processed as a format string against the provided arguments

func (*Logger) Print

func (l *Logger) Print(args ...interface{})

Print logs messages at the Print level after combining all arguments into a single string

func (*Logger) Printf

func (l *Logger) Printf(s string, args ...interface{})

Printf logs messages at the Print level after processing the string and its arguments as a format string

func (*Logger) Warn

func (l *Logger) Warn(args ...interface{})

Warn logs messages at the Warn level after combining the provided arguments into a single string

func (*Logger) Warnf

func (l *Logger) Warnf(s string, args ...interface{})

Warnf logs messages at the Warn level after processing the string as a format string against the provided arguments

Jump to

Keyboard shortcuts

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