integrationtest

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2025 License: GPL-3.0 Imports: 21 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 CreateEnvForDaemon added in v1.0.0

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

CreateEnvForDaemon performs the minimum required operations to start the arduino-cli daemon. It returns a testsuite.Environment and an ArduinoCLI client to perform the integration tests. The Environment must be disposed by calling the CleanUp method via defer.

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) InstallMockedAvrdude added in v1.1.0

func (cli *ArduinoCLI) InstallMockedAvrdude(t *testing.T)

InstallMockedAvrdude will replace the already installed avrdude with a mocked one.

func (*ArduinoCLI) InstallMockedSerialDiscovery added in v1.0.0

func (cli *ArduinoCLI) InstallMockedSerialDiscovery(t *testing.T)

InstallMockedSerialDiscovery will replace the already installed serial-discovery with a mocked one.

func (*ArduinoCLI) InstallMockedSerialMonitor added in v1.0.0

func (cli *ArduinoCLI) InstallMockedSerialMonitor(t *testing.T)

InstallMockedSerialMonitor will replace the already installed serial-monitor with a mocked one.

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) RunWithCustomInput added in v1.0.0

func (cli *ArduinoCLI) RunWithCustomInput(in io.Reader, args ...string) ([]byte, []byte, error)

RunWithCustomInput executes the given arduino-cli command pushing the given input stream 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) BoardIdentify added in v1.2.0

func (inst *ArduinoCLIInstance) BoardIdentify(ctx context.Context, props map[string]string, useCloudAPI bool) (*commands.BoardIdentifyResponse, error)

BoardIdentify calls the "BoardIdentify" gRPC method.

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(ctx context.Context) (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) Monitor added in v1.0.0

func (inst *ArduinoCLIInstance) Monitor(ctx context.Context, port *commands.Port) (commands.ArduinoCoreService_MonitorClient, error)

Monitor calls the "Monitor" gRPC method and sends the OpenRequest message.

func (*ArduinoCLIInstance) NewSketch added in v1.2.1

func (inst *ArduinoCLIInstance) NewSketch(ctx context.Context, sketchName, sketchDir string, overwrite bool) (*commands.NewSketchResponse, error)

NewSketch calls the "NewSketch" 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) PlatformSearch added in v1.0.0

func (inst *ArduinoCLIInstance) PlatformSearch(ctx context.Context, args string, all bool) (*commands.PlatformSearchResponse, error)

PlatformSearch calls the "PlatformSearch" 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.

func (*ArduinoCLIInstance) Upload added in v1.1.0

func (inst *ArduinoCLIInstance) Upload(ctx context.Context, fqbn, sketchPath, port, protocol string) (commands.ArduinoCoreService_UploadClient, error)

Upload calls the "Upload" 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
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy