test

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Poll

func Poll(fn PollFunc, opts PollOptions) error

Poll executes the given function `fn` until it returns no error, or until the configured number of tries or timeout is reached.

func Test

func Test(t *testing.T, tc TestCase)

func WriteTestFile added in v0.6.0

func WriteTestFile(t *testing.T, contents io.Reader) (string, error)

WriteTestFile writes the provided contents from the reader into a newly created random-named file inside t.TempDir(). The created file has restrictive permissions (0600). It returns the full path to the created file or an error.

func WriteTestFileWithName added in v0.6.0

func WriteTestFileWithName(t *testing.T, filename string, contents io.Reader) (string, error)

WriteTestFileWithName writes the provided contents from the reader into a file with the specified name inside t.TempDir(). The created file has restrictive permissions (0600). It returns the full path to the created file or an error.

Types

type PollFunc

type PollFunc func() error

PollFunc is the function to be executed by the Poll function. It should return an error to indicate a failure and that it should be retried. A nil error indicates success.

type PollOptions

type PollOptions struct {
	// Tries is the maximum number of times to try the function.
	// If Tries is 0, it will retry until Timeout is reached.
	Tries int
	// Delay is the time to wait between retries.
	// If Delay is 0, binary exponential backoff is used, starting at 2 seconds.
	Delay time.Duration
	// Timeout is the maximum total time to spend retrying.
	// If Timeout is 0, there is no time limit.
	Timeout time.Duration
}

PollOptions configures the behavior of the Poll function.

type Step

type Step struct {
	PreRun  func(TestContext) error
	Run     func(TestContext) error
	PostRun func(TestContext) error
	Verify  func(TestContext) error
}

Compact acc runner

type TestCase

type TestCase struct {
	PreCheck func() error
	Steps    []Step
}

type TestContext

type TestContext interface {
	util.CmdContext
	Org() string
	OrgUrl() string
	PAT() string
	Project() string
	SetValue(key, value any)
	Value(key any) (any, bool)
}

Jump to

Keyboard shortcuts

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