integrationtest

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ProjectName = "cli"

ProjectName is the prefix used in the test temp files

Functions

func CreateArduinoCLIWithEnvironment

func CreateArduinoCLIWithEnvironment(t *testing.T) (*Environment, *ArduinoCLI)

CreateArduinoCLIWithEnvironment performs the minimum amount of actions to build the default test environment.

func FindArduinoCLIPath

func FindArduinoCLIPath(t *testing.T) *paths.Path

FindArduinoCLIPath returns the path to the arduino-cli executable

func FindRepositoryRootPath

func FindRepositoryRootPath(t *testing.T) *paths.Path

FindRepositoryRootPath returns the repository root path

Types

type ArduinoCLI

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

ArduinoCLI is an Arduino CLI client.

func NewArduinoCliWithinEnvironment

func NewArduinoCliWithinEnvironment(env *Environment, config *ArduinoCLIConfig) *ArduinoCLI

NewArduinoCliWithinEnvironment creates a new Arduino CLI client inside the given environment.

func (*ArduinoCLI) CleanUp

func (cli *ArduinoCLI) CleanUp()

CleanUp closes the Arduino CLI client.

func (*ArduinoCLI) CopySketch

func (cli *ArduinoCLI) CopySketch(sketchName string) *paths.Path

CopySketch copies a sketch inside the testing environment and returns its path

func (*ArduinoCLI) Create

func (cli *ArduinoCLI) Create() *ArduinoCLIInstance

Create calls the "Create" gRPC method.

func (*ArduinoCLI) DataDir

func (cli *ArduinoCLI) DataDir() *paths.Path

DataDir returns the data directory

func (*ArduinoCLI) DownloadDir

func (cli *ArduinoCLI) DownloadDir() *paths.Path

DownloadDir returns the download directory

func (*ArduinoCLI) GetDefaultEnv

func (cli *ArduinoCLI) GetDefaultEnv() map[string]string

GetDefaultEnv returns a copy of the default execution env used with the Run method.

func (*ArduinoCLI) Run

func (cli *ArduinoCLI) Run(args ...string) ([]byte, []byte, error)

Run executes the given arduino-cli command and returns the output.

func (*ArduinoCLI) RunWithCustomEnv

func (cli *ArduinoCLI) RunWithCustomEnv(env map[string]string, args ...string) ([]byte, []byte, error)

RunWithCustomEnv executes the given arduino-cli command with the given custom env and returns the output.

func (*ArduinoCLI) SetValue

func (cli *ArduinoCLI) SetValue(key, jsonData string) error

SetValue calls the "SetValue" gRPC method.

func (*ArduinoCLI) SetWorkingDir

func (cli *ArduinoCLI) SetWorkingDir(p *paths.Path)

SetWorkingDir sets a new working directory

func (*ArduinoCLI) SketchbookDir

func (cli *ArduinoCLI) SketchbookDir() *paths.Path

SketchbookDir returns the sketchbook directory

func (*ArduinoCLI) StartDaemon

func (cli *ArduinoCLI) StartDaemon(verbose bool) string

StartDaemon starts the Arduino CLI daemon. It returns the address of the daemon.

func (*ArduinoCLI) WorkingDir

func (cli *ArduinoCLI) WorkingDir() *paths.Path

WorkingDir returns the working directory

type ArduinoCLIConfig

type ArduinoCLIConfig struct {
	ArduinoCLIPath         *paths.Path
	UseSharedStagingFolder bool
}

ArduinoCLIConfig is the configuration of the ArduinoCLI client

type ArduinoCLIInstance

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

ArduinoCLIInstance is an Arduino CLI gRPC instance.

func (*ArduinoCLIInstance) BoardList

func (inst *ArduinoCLIInstance) BoardList(timeout time.Duration) (*commands.BoardListResponse, error)

BoardList calls the "BoardList" gRPC method.

func (*ArduinoCLIInstance) BoardListWatch

func (inst *ArduinoCLIInstance) BoardListWatch() (commands.ArduinoCoreService_BoardListWatchClient, error)

BoardListWatch calls the "BoardListWatch" gRPC method.

func (*ArduinoCLIInstance) Compile

func (inst *ArduinoCLIInstance) Compile(ctx context.Context, fqbn, sketchPath string, warnings string) (commands.ArduinoCoreService_CompileClient, error)

Compile calls the "Compile" gRPC method.

func (*ArduinoCLIInstance) Init

func (inst *ArduinoCLIInstance) Init(profile string, sketchPath string, respCB func(*commands.InitResponse)) error

Init calls the "Init" gRPC method.

func (*ArduinoCLIInstance) LibraryInstall

func (inst *ArduinoCLIInstance) LibraryInstall(ctx context.Context, name, version string, noDeps, noOverwrite, installAsBundled bool) (commands.ArduinoCoreService_LibraryInstallClient, error)

LibraryInstall calls the "LibraryInstall" gRPC method.

func (*ArduinoCLIInstance) LibraryList

func (inst *ArduinoCLIInstance) LibraryList(ctx context.Context, name, fqbn string, all, updatable bool) (*commands.LibraryListResponse, error)

LibraryList calls the "LibraryList" gRPC method.

func (*ArduinoCLIInstance) LibraryUninstall

func (inst *ArduinoCLIInstance) LibraryUninstall(ctx context.Context, name, version string) (commands.ArduinoCoreService_LibraryUninstallClient, error)

LibraryUninstall calls the "LibraryUninstall" gRPC method.

func (*ArduinoCLIInstance) PlatformInstall

func (inst *ArduinoCLIInstance) PlatformInstall(ctx context.Context, packager, arch, version string, skipPostInst bool) (commands.ArduinoCoreService_PlatformInstallClient, error)

PlatformInstall calls the "PlatformInstall" gRPC method.

func (*ArduinoCLIInstance) PlatformList

func (inst *ArduinoCLIInstance) PlatformList(ctx context.Context) (*commands.PlatformListResponse, error)

PlatformList calls the "PlatformList" gRPC method.

func (*ArduinoCLIInstance) PlatformUpgrade

func (inst *ArduinoCLIInstance) PlatformUpgrade(ctx context.Context, packager, arch string, skipPostInst bool) (commands.ArduinoCoreService_PlatformUpgradeClient, error)

PlatformUpgrade calls the "PlatformUpgrade" gRPC method.

func (*ArduinoCLIInstance) UpdateIndex

func (inst *ArduinoCLIInstance) UpdateIndex(ctx context.Context, ignoreCustomPackages bool) (commands.ArduinoCoreService_UpdateIndexClient, error)

UpdateIndex calls the "UpdateIndex" gRPC method.

type CLISubtests

type CLISubtests []struct {
	Name     string
	Function func(*testing.T, *Environment, *ArduinoCLI)
}

CLISubtests is a suite of tests to run under the same integreationtest.Environment

func (CLISubtests) Run

func (testSuite CLISubtests) Run(t *testing.T, env *Environment, cli *ArduinoCLI)

Run runs the test suite as subtests of the current test

type Environment

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

Environment is a test environment for the test suite.

func NewEnvironment

func NewEnvironment(t *testing.T) *Environment

NewEnvironment creates a new test environment.

func (*Environment) CleanUp

func (e *Environment) CleanUp()

CleanUp removes the test environment.

func (*Environment) HTTPServeFile

func (env *Environment) HTTPServeFile(port uint16, path *paths.Path) *url.URL

HTTPServeFile spawn an http server that serve a single file. The server is started on the given port. The URL to the file and a cleanup function are returned.

func (*Environment) HTTPServeFileError

func (env *Environment) HTTPServeFileError(port uint16, path *paths.Path, code int) *url.URL

HTTPServeFileError spawns an http server that serves a single file and responds with the given error code.

func (*Environment) RegisterCleanUpCallback

func (e *Environment) RegisterCleanUpCallback(newCleanUp func())

RegisterCleanUpCallback adds a clean up function to the clean up chain

func (*Environment) RootDir

func (e *Environment) RootDir() *paths.Path

RootDir returns the root dir of the environment.

func (*Environment) SharedDownloadsDir

func (e *Environment) SharedDownloadsDir() *SharedDir

SharedDownloadsDir return the shared directory for downloads

func (*Environment) T

func (e *Environment) T() *testing.T

T returns the testing environment

type SharedDir

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

SharedDir is a directory that is shared between multiple tests.

func NewSharedDir

func NewSharedDir(t *testing.T, id string) *SharedDir

NewSharedDir creates a new shared directory.

func (*SharedDir) Lock

func (d *SharedDir) Lock() *paths.Path

Lock locks the shared directory for exclusive access and return the path to the directory.

func (*SharedDir) Unlock

func (d *SharedDir) Unlock()

Unlock unlocks the shared directory.

Jump to

Keyboard shortcuts

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