utils

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TestWorkspaceName        = "test"
	TestWorkspaceDisplayName = "Test Workspace"
)

Variables

This section is empty.

Functions

func ExecWithCmd

func ExecWithCmd(cmd string) gomock.Matcher

func ExecWithRef

func ExecWithRef(ref executable.Ref) gomock.Matcher

func FindSubExecs

func FindSubExecs(rootExec *executable.Executable, flowFiles executable.FlowFileList) executable.ExecutableList

FindSubExecs returns a list of sub-executables for the given root executable.

func MaybeUpdateGolden

func MaybeUpdateGolden(tb testing.TB, out []byte)

func NormalizeTmpDirs

func NormalizeTmpDirs(input string) string

NormalizeTmpDirs replaces all file paths under the system temp dir with /TMPDIR.

func RequireEqualSnapshot

func RequireEqualSnapshot(tb testing.TB, out []byte)

func ResetTestContext

func ResetTestContext(ctx *Context, tb testing.TB)

func UpdateGolden

func UpdateGolden(tb testing.TB, out []byte)

Types

type CommandRunner

type CommandRunner struct{}

func NewE2ECommandRunner

func NewE2ECommandRunner() *CommandRunner

func (*CommandRunner) Run

func (r *CommandRunner) Run(ctx *context.Context, args ...string) (err error)

type Context

type Context struct {
	*context.Context
	// contains filtered or unexported fields
}

func NewContext

func NewContext(ctx stdCtx.Context, tb testing.TB) *Context

NewContext creates a new context for testing runners. It initializes the context with a real logger that writes it's output to a temporary file. It also creates a temporary testing directory for the test workspace, user configs, and caches. Test environment variables are set the config and cache directories override paths.

func (*Context) ExitCalls

func (c *Context) ExitCalls() []string

ExitCalls returns the fatal messages captured while the context was in failure-capture mode.

func (*Context) ExpectFailure

func (c *Context) ExpectFailure()

ExpectFailure flips the test context into capture mode: subsequent fatal logger calls will be recorded on the context and cause the currently executing command to return an error instead of failing the test. Reset on every ResetTestContext call.

func (*Context) WorkspaceDir

func (c *Context) WorkspaceDir() string

type ContextWithMocks

type ContextWithMocks struct {
	Ctx             *context.Context
	Logger          *tuikitIOMocks.MockLogger
	ExecutableCache *cacheMocks.MockExecutableCache
	WorkspaceCache  *cacheMocks.MockWorkspaceCache
	RunnerMock      *mocks.MockRunner
}

func NewContextWithMocks

func NewContextWithMocks(ctx stdCtx.Context, tb testing.TB) *ContextWithMocks

NewContextWithMocks creates a new context for testing runners. It initializes the context with a mock logger and mock caches. The mock logger is set to expect debug calls.

type ExitRecorder

type ExitRecorder struct {
	// contains filtered or unexported fields
}

ExitRecorder routes logger fatal calls so they can be asserted on in tests rather than aborting the process or the test goroutine.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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