testutil

package
v0.0.0-...-3fd9045 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2023 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package testutil is a collection of supporting code to run packer integration tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsBuildkitAvailable

func IsBuildkitAvailable() error

IsBuildkitAvailable returns nil if buildkit is ready to use.

func IsDockerAvailable

func IsDockerAvailable() error

IsDockerAvailable returns nil if docker buildx is ready to use.

Types

type BuildkitRunner

type BuildkitRunner struct {
	CommandRunner
	Target   string
	Platform string
}

BuildkitRunner runs packer via buildctl/buildkit.

func (BuildkitRunner) Run

func (runner BuildkitRunner) Run(t *testing.T)

Run implements Run interface.

type CommandRunner

type CommandRunner struct {
	ExpectStdout *string
	Expect       string
}

CommandRunner is an abstract runner mix-in which processes command result.

type DockerRunner

type DockerRunner struct {
	CommandRunner
	Target   string
	Platform string
}

DockerRunner runs packer via docker buildx.

func (DockerRunner) Run

func (runner DockerRunner) Run(t *testing.T)

Run implements Run interface.

type EvalRunner

type EvalRunner struct {
	CommandRunner

	Target   string
	Template string
}

EvalRunner runs packer eval.

func (EvalRunner) Run

func (runner EvalRunner) Run(t *testing.T)

Run implements Run interface.

type IntegrationTest

type IntegrationTest struct {
	Name     string
	Path     string
	Manifest TestManifest
}

IntegrationTest describes single integration set (common testdata).

func (IntegrationTest) Run

func (test IntegrationTest) Run(t *testing.T)

Run executes integration test.

type LLBRunner

type LLBRunner struct {
	CommandRunner
	Target   string
	Platform string
}

LLBRunner runs packer via packer llb | buildctl.

func (LLBRunner) Run

func (runner LLBRunner) Run(t *testing.T)

Run implements Run interface.

type Run

type Run interface {
	Run(t *testing.T)
}

Run the integration test.

type RunManifest

type RunManifest struct {
	Name         string  `yaml:"name"`
	Runner       string  `yaml:"runner"`
	Platform     string  `yaml:"platform"`
	Target       string  `yaml:"target"`
	Expect       string  `yaml:"expect"`
	ExpectStdout *string `yaml:"expectStdout"`
	CreateFile   string  `yaml:"createFile"`
	Template     string  `yaml:"template"`
}

RunManifest describes single run of integration test.

type TestCollection

type TestCollection struct {
	Tests []IntegrationTest
}

TestCollection is a set of integration tests.

func CollectTests

func CollectTests() (*TestCollection, error)

CollectTests builds TestCollection from directory structure.

func (*TestCollection) Each

func (collection *TestCollection) Each(f func(string, func(t *testing.T)))

Each iterates over collection providing runner for each test.

type TestManifest

type TestManifest struct {
	Runs []RunManifest `yaml:"run"`
}

TestManifest describes single integration test in test.yaml.

func NewTestManifest

func NewTestManifest(path string) (manifest TestManifest, err error)

NewTestManifest loads TestManifest from test.yaml file.

type ValidateRunner

type ValidateRunner struct {
	CommandRunner
}

ValidateRunner runs packer validate.

func (ValidateRunner) Run

func (runner ValidateRunner) Run(t *testing.T)

Run implements Run interface.

Jump to

Keyboard shortcuts

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