tests

package
v2.1.57 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertDirContentsEqual

func AssertDirContentsEqual(t *testing.T, expectedDir string, actualDir string)

AssertDirContentsEqual walks two directory structures and validates that the same files exist (by name) and that they have the same content

func AssertDirDoesNotExist

func AssertDirDoesNotExist(t *testing.T, dir string) bool

AssertDirDoesNotExist asserts that the given directory does not exist

func AssertDirExists

func AssertDirExists(t *testing.T, dir string) bool

AssertDirExists asserts that the given directory exists

func AssertDirsExist

func AssertDirsExist(t *testing.T, expected bool, paths ...string)

AssertDirsExist asserts that the list of directory paths either exist or don't exist

func AssertEqualFileText

func AssertEqualFileText(t *testing.T, expectedFile string, actualFile string) error

func AssertFileContains

func AssertFileContains(t *testing.T, fileName string, containsText string)

AssertFileContains asserts that a given file exists and contains the given text

func AssertFileDoesNotContain

func AssertFileDoesNotContain(t *testing.T, fileName string, containsText string)

AssertFileDoesNotContain asserts that a given file exists and does not contain the given text

func AssertFileDoesNotExist

func AssertFileDoesNotExist(t *testing.T, fileName string) bool

AssertFileDoesNotExist asserts that the given file does not exist

func AssertFileExists

func AssertFileExists(t *testing.T, fileName string) bool

AssertFileExists asserts that the given file exists

func AssertFilesExist

func AssertFilesExist(t *testing.T, expected bool, paths ...string)

AssertFilesExist asserts that the list of file paths either exist or don't exist

func AssertLoadFileText

func AssertLoadFileText(t *testing.T, fileName string) (string, error)

AssertLoadFileText asserts that the given file name can be loaded and returns the string contents

func AssertTextFileContentsEqual

func AssertTextFileContentsEqual(t *testing.T, expectedFile string, actualFile string)

AssertTextFileContentsEqual asserts that both the expected and actual files can be loaded as text and that their contents are identical

func CreateAuthConfigService

func CreateAuthConfigService() auth.ConfigService

CreateAuthConfigService creates and returns a fixture ConfigService

func Debugf

func Debugf(message string, args ...interface{})

Debugf debug format

func ExpectString

func ExpectString(t *testing.T, console *expect.Console, s string)

ExpectString does the same as the go-expect console.ExpectString method, but also reports failures to the testing object in a sensible format

func IsDebugLog

func IsDebugLog() bool

IsDebugLog debug log?

func Output

func Output() terminal.FileWriter

Output returns the output to use for tests

func Retry

func Retry(t *testing.T, maxAttempts int, sleep time.Duration, f func(r *R)) bool

Retry runs function f for up to maxAttempts times until f returns successfully, and reports whether f was run successfully. It will sleep for the given period between invocations of f. Use the provided *tests.R instead of a *testing.T from the function.

func SkipForWindows

func SkipForWindows(t *testing.T, reason string)

SkipForWindows skips tests if they are running on Windows This is to be used for valid tests that just don't work on windows for whatever reason

func TestCloser

func TestCloser(t *testing.T, closer io.Closer)

TestCloser closes io

func TestShouldDisableMaven

func TestShouldDisableMaven() bool

TestShouldDisableMaven should disable maven

Types

type ConsoleWrapper

type ConsoleWrapper struct {
	terminal.Stdio
	// contains filtered or unexported fields
}

ConsoleWrapper is a wrapper around the go-expect Console that takes a test object and will report failures This prevents users having to manually detect and report errors during the tests

func NewTerminal

func NewTerminal(t assert.TestingT, timeout *time.Duration) *ConsoleWrapper

NewTerminal mock terminal to control stdin and stdout

func (*ConsoleWrapper) Cleanup

func (c *ConsoleWrapper) Cleanup()

Cleanup closes all resources the console was using

func (*ConsoleWrapper) Close

func (c *ConsoleWrapper) Close()

Close closes the console input

func (*ConsoleWrapper) CurrentState

func (c *ConsoleWrapper) CurrentState() string

CurrentState gets the last line of text currently on the console

func (*ConsoleWrapper) ExpectEOF

func (c *ConsoleWrapper) ExpectEOF()

ExpectEOF expects an EOF to be present on the console and reports an error if it is not

func (*ConsoleWrapper) ExpectString

func (c *ConsoleWrapper) ExpectString(s string)

ExpectString expects a string to be present on the console and fails the test if it is not

func (*ConsoleWrapper) SendLine

func (c *ConsoleWrapper) SendLine(s string)

SendLine sends a string to the console and fails the test if something goes wrong

type R

type R struct {
	// The number of current attempt.
	Attempt int
	// contains filtered or unexported fields
}

R is passed to each run of a flaky test run, manages state and accumulates log statements.

func (*R) Errorf

func (r *R) Errorf(s string, v ...interface{})

Errorf is equivalent to Logf followed by Fail.

func (*R) Fail

func (r *R) Fail()

Fail marks the run as failed, and will retry once the function returns.

func (*R) Logf

func (r *R) Logf(s string, v ...interface{})

Logf formats its arguments and records it in the error log. The text is only printed for the final unsuccessful run or the first successful run.

Jump to

Keyboard shortcuts

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