Documentation ¶
Overview ¶
Example (GetJobID) ¶
fmt.Println(getJobID("https://app.saucelabs.com/tests/cb6741a1a119448a9760531024657967"))
Output: cb6741a1a119448a9760531024657967
Index ¶
- Constants
- func NewImagePullOptions() (types.ImagePullOptions, error)
- type CommonAPIClient
- type ContainerRunner
- type CypressRunner
- type Handler
- func (handler *Handler) ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error)
- func (handler *Handler) ContainerRemove(ctx context.Context, srcContainerID string) error
- func (handler *Handler) ContainerStop(ctx context.Context, srcContainerID string) error
- func (handler *Handler) CopyFromContainer(ctx context.Context, srcContainerID string, srcPath string, dstPath string) error
- func (handler *Handler) CopyToContainer(ctx context.Context, containerID string, srcFile string, targetDir string, ...) error
- func (handler *Handler) Execute(ctx context.Context, srcContainerID string, cmd []string) (*types.IDResponse, *types.HijackedResponse, error)
- func (handler *Handler) ExecuteAttach(ctx context.Context, containerID string, cmd []string) (int, string, error)
- func (handler *Handler) ExecuteInspect(ctx context.Context, srcContainerID string) (int, error)
- func (handler *Handler) GetBrowserVersion(ctx context.Context, imageID string, browser string) string
- func (handler *Handler) HasBaseImage(ctx context.Context, baseImage string) (bool, error)
- func (handler *Handler) IsErrNotFound(err error) bool
- func (handler *Handler) IsErrRemovalInProgress(err error) bool
- func (handler *Handler) IsInstalled() bool
- func (handler *Handler) IsLaunchable(image string) error
- func (handler *Handler) JobInfoFile(ctx context.Context, imageID string) (string, error)
- func (handler *Handler) ProjectDir(ctx context.Context, imageID string) (string, error)
- func (handler *Handler) PullImage(ctx context.Context, img string) error
- func (handler *Handler) StartContainer(ctx context.Context, options containerStartOptions) (*container.ContainerCreateCreatedBody, error)
- func (handler *Handler) Teardown(ctx context.Context, containerID string) error
- type PlaywrightRunner
- type PuppeterRunner
- type TestcafeRunner
Examples ¶
Constants ¶
const RegistryPasswordEnvKey = "REGISTRY_PASSWORD"
RegistryPasswordEnvKey represents the password environment variable for authenticating against a docker registry.
const RegistryUsernameEnvKey = "REGISTRY_USERNAME"
RegistryUsernameEnvKey represents the username environment variable for authenticating against a docker registry.
const SauceRunnerConfigFile = "sauce-runner.json"
SauceRunnerConfigFile represents the filename for the sauce runner configuration.
Variables ¶
This section is empty.
Functions ¶
func NewImagePullOptions ¶
func NewImagePullOptions() (types.ImagePullOptions, error)
NewImagePullOptions returns a new types.ImagePullOptions object. Credentials are also configured, if available via environment variables (see RegistryUsernameEnvKey and RegistryPasswordEnvKey).
Types ¶
type CommonAPIClient ¶
type CommonAPIClient interface { ServerVersion(ctx context.Context) (types.Version, error) ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error) ImageList(ctx context.Context, options types.ImageListOptions) ([]types.ImageSummary, error) ImagePull(ctx context.Context, ref string, options types.ImagePullOptions) (io.ReadCloser, error) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *specs.Platform, containerName string) (container.ContainerCreateCreatedBody, error) ContainerStart(ctx context.Context, containerID string, options types.ContainerStartOptions) error ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error) CopyToContainer(ctx context.Context, container, path string, content io.Reader, options types.CopyToContainerOptions) error ContainerStatPath(ctx context.Context, containerID, path string) (types.ContainerPathStat, error) CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, types.ContainerPathStat, error) ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error) ContainerExecAttach(ctx context.Context, execID string, config types.ExecStartCheck) (types.HijackedResponse, error) ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error) ContainerStop(ctx context.Context, containerID string, timeout *time.Duration) error ContainerRemove(ctx context.Context, containerID string, options types.ContainerRemoveOptions) error ImageInspectWithRaw(ctx context.Context, imageID string) (types.ImageInspect, []byte, error) }
CommonAPIClient is the interface for interacting with containers.
type ContainerRunner ¶ added in v0.25.2
type ContainerRunner struct { Ctx context.Context Framework framework.Framework FrameworkMeta framework.MetadataService JobWriter job.Writer ShowConsoleLog bool JobReader job.Reader ArtfactDownloader job.ArtifactDownloader MetadataSearchStrategy framework.MetadataSearchStrategy Reporters []report.Reporter // contains filtered or unexported fields }
ContainerRunner represents the container runner for docker.
type CypressRunner ¶ added in v0.25.0
type CypressRunner struct { ContainerRunner Project cypress.Project }
CypressRunner represents the docker implementation of a test runner.
func NewCypress ¶ added in v0.25.0
func NewCypress(c cypress.Project, ms framework.MetadataService, wr job.Writer, jr job.Reader, dl job.ArtifactDownloader, reps []report.Reporter) (*CypressRunner, error)
NewCypress creates a new CypressRunner instance.
func (*CypressRunner) RunProject ¶ added in v0.25.0
func (r *CypressRunner) RunProject() (int, error)
RunProject runs the tests defined in config.Project.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler represents the client to handle Docker tasks
func CreateMock ¶
func CreateMock(client CommonAPIClient) *Handler
CreateMock allows to get a handler with a custom interface
func (*Handler) ContainerInspect ¶ added in v0.21.0
func (handler *Handler) ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error)
ContainerInspect returns the container information.
func (*Handler) ContainerRemove ¶
ContainerRemove removes testrunner container
func (*Handler) ContainerStop ¶
ContainerStop stops a running container
func (*Handler) CopyFromContainer ¶
func (handler *Handler) CopyFromContainer(ctx context.Context, srcContainerID string, srcPath string, dstPath string) error
CopyFromContainer downloads a file from the testrunner container
func (*Handler) CopyToContainer ¶
func (handler *Handler) CopyToContainer(ctx context.Context, containerID string, srcFile string, targetDir string, matcher sauceignore.Matcher) error
CopyToContainer copies the given file to the container.
func (*Handler) Execute ¶
func (handler *Handler) Execute(ctx context.Context, srcContainerID string, cmd []string) (*types.IDResponse, *types.HijackedResponse, error)
Execute runs the test in the Docker container and attaches to its stdout
func (*Handler) ExecuteAttach ¶ added in v0.25.2
func (handler *Handler) ExecuteAttach(ctx context.Context, containerID string, cmd []string) (int, string, error)
ExecuteAttach runs the cmd test in the Docker container and catch the given stream to a string.
func (*Handler) ExecuteInspect ¶
ExecuteInspect checks exit code of test
func (*Handler) GetBrowserVersion ¶ added in v0.52.4
func (handler *Handler) GetBrowserVersion(ctx context.Context, imageID string, browser string) string
GetBrowserVersion gets the given browser's version from an image's labels
func (*Handler) HasBaseImage ¶
HasBaseImage checks if base image is installed
func (*Handler) IsErrNotFound ¶ added in v0.21.0
IsErrNotFound returns true if the error is a NotFound error, which is returned by the API when some object is not found.
func (*Handler) IsErrRemovalInProgress ¶ added in v0.35.0
IsErrRemovalInProgress returns true if error is meaning removal is in progress.
func (*Handler) IsInstalled ¶ added in v0.25.3
IsInstalled checks if docker is installed.
func (*Handler) IsLaunchable ¶ added in v0.80.0
IsLaunchable checks if the given image is launchable by spawning a container and cleaning it up right after.
func (*Handler) JobInfoFile ¶ added in v0.28.0
JobInfoFile returns the file containing the job details url for the given image.
func (*Handler) ProjectDir ¶ added in v0.25.0
ProjectDir returns the project directory as is configured for the given image.
func (*Handler) StartContainer ¶
func (handler *Handler) StartContainer(ctx context.Context, options containerStartOptions) (*container.ContainerCreateCreatedBody, error)
StartContainer starts the Docker testrunner container
type PlaywrightRunner ¶ added in v0.25.0
type PlaywrightRunner struct { ContainerRunner Project playwright.Project }
PlaywrightRunner represents the docker implementation of a test runner.
func NewPlaywright ¶ added in v0.25.0
func NewPlaywright(c playwright.Project, ms framework.MetadataService, wr job.Writer, jr job.Reader, dl job.ArtifactDownloader, reps []report.Reporter) (*PlaywrightRunner, error)
NewPlaywright creates a new PlaywrightRunner instance.
func (*PlaywrightRunner) RunProject ¶ added in v0.25.0
func (r *PlaywrightRunner) RunProject() (int, error)
RunProject runs the tests defined in config.Project.
type PuppeterRunner ¶ added in v0.34.0
type PuppeterRunner struct { ContainerRunner Project puppeteer.Project }
PuppeterRunner represents the docker implementation of a test runner.
func NewPuppeteer ¶ added in v0.34.0
func NewPuppeteer(c puppeteer.Project, ms framework.MetadataService, wr job.Writer, jr job.Reader, dl job.ArtifactDownloader, reps []report.Reporter) (*PuppeterRunner, error)
NewPuppeteer creates a new PuppeterRunner instance.
func (*PuppeterRunner) RunProject ¶ added in v0.34.0
func (r *PuppeterRunner) RunProject() (int, error)
RunProject runs the tests defined in config.Project.
type TestcafeRunner ¶ added in v0.29.0
type TestcafeRunner struct { ContainerRunner Project testcafe.Project }
TestcafeRunner represents the docker implementation of a test runner.
func NewTestcafe ¶ added in v0.29.0
func NewTestcafe(c testcafe.Project, ms framework.MetadataService, wr job.Writer, jr job.Reader, dl job.ArtifactDownloader, reps []report.Reporter) (*TestcafeRunner, error)
NewTestcafe creates a new TestcafeRunner instance.
func (*TestcafeRunner) RunProject ¶ added in v0.29.0
func (r *TestcafeRunner) RunProject() (int, error)
RunProject runs the tests defined in config.Project.