runtest

package
v0.0.0-...-b5d9cbe Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Overview

Package runtest provides fake implementations needed to test Tast CLI.

Index

Constants

View Source
const (
	// LocalTestRunnerPath is the path to the fake local test runner
	// available on the SSH server.
	LocalTestRunnerPath = "/fake/mock_local_test_runner"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DUTOption

type DUTOption func(*dutConfig)

DUTOption can be passed to SetUp to configure the primary DUT, or to WithCompanionDUT to configure a companion DUT.

func WithBootID

func WithBootID(f func() (bootID string, err error)) DUTOption

WithBootID specifies a function called to compute a boot ID.

func WithCollectSysInfo

func WithCollectSysInfo(f func(req *protocol.CollectSysInfoRequest) (*protocol.CollectSysInfoResponse, error)) DUTOption

WithCollectSysInfo specifies a function that implements CollectSysInfo handler.

func WithDownloadPrivateBundles

WithDownloadPrivateBundles specifies a function that implements DownloadPrivateBundles handler.

func WithExtraSSHHandlers

func WithExtraSSHHandlers(handlers []fakesshserver.Handler) DUTOption

WithExtraSSHHandlers specifies extra SSH handlers installed to a fake SSH server.

func WithGetDUTInfo

func WithGetDUTInfo(f func(req *protocol.GetDUTInfoRequest) (*protocol.GetDUTInfoResponse, error)) DUTOption

WithGetDUTInfo specifies a function that implements GetDUTInfo handler.

func WithGetSysInfoState

func WithGetSysInfoState(f func(req *protocol.GetSysInfoStateRequest) (*protocol.GetSysInfoStateResponse, error)) DUTOption

WithGetSysInfoState specifies a function that implements GetSysInfoState handler.

func WithOnRunLocalTestsInit

func WithOnRunLocalTestsInit(f func(init *protocol.RunTestsInit, bcfg *protocol.BundleConfig)) DUTOption

WithOnRunLocalTestsInit specifies a function that is called on the beginning of RunTests for the local test runner.

func WithStreamFile

WithStreamFile specifies a function that implements StreamFile handler.

type Env

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

Env contains information needed to interact with the testing environment set up.

func SetUp

func SetUp(t *gotesting.T, opts ...EnvOrDUTOption) *Env

SetUp sets up a testing environment for Tast CLI.

Call this function at the beginning of unit tests to set up various fakes commonly needed by Tast CLI, e.g. a fake SSH server and fake test runners.

The environment is cleaned up automatically on the end of the current unit test.

func (*Env) Config

func (e *Env) Config(mod func(cfg *config.MutableConfig)) *config.Config

Config returns a Config struct with reasonable default values to be used in unit tests. Callers can pass non-nil mod to alter values of a returned Config struct if needed to customize Tast CLI component behavior.

func (*Env) Context

func (e *Env) Context() context.Context

Context returns a background context. loggingtest.Logger is attached to the context so that logs are routed to unit test logs.

func (*Env) State

func (e *Env) State() *config.DeprecatedState

State returns a State struct to be used in unit tests. It is cleaned up on the end of the current unit test.

func (*Env) TempDir

func (e *Env) TempDir() string

TempDir returns a directory path where callers can save arbitrary temporary files. This directory is cleared on the end of the current unit test.

type EnvOption

type EnvOption func(*envConfig)

EnvOption can be passed to SetUp to customize the testing environment.

func WithCompanionDUT

func WithCompanionDUT(role string, opts ...DUTOption) EnvOption

WithCompanionDUT adds a companion DUT.

func WithLocalBundles

func WithLocalBundles(bs ...*testing.Registry) EnvOption

WithLocalBundles specifies fake local test bundles to be installed.

func WithOnRunRemoteTestsInit

func WithOnRunRemoteTestsInit(f func(init *protocol.RunTestsInit, bcfg *protocol.BundleConfig)) EnvOption

WithOnRunRemoteTestsInit specifies a function that is called on the beginning of RunTests for the remote test runner.

func WithRemoteBundles

func WithRemoteBundles(bs ...*testing.Registry) EnvOption

WithRemoteBundles specifies fake remote test bundles to be installed.

type EnvOrDUTOption

type EnvOrDUTOption interface {
	// contains filtered or unexported methods
}

EnvOrDUTOption is an interface satisfied by EnvOption and DUTOption.

Directories

Path Synopsis
internal
fakerunner
Package fakerunner provides a fake implementation of test runners.
Package fakerunner provides a fake implementation of test runners.

Jump to

Keyboard shortcuts

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