Help us shape the future of Go! Take the 2026 Go Developer Survey

acctest

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2025 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupPurgeJob

func CleanupPurgeJob(s *TestState) error

CleanupPurgeJob is a cleanup func to purge the TestCase job from Nomad

func Test

func Test(t *testing.T, c TestCase)

Test executes a single TestCase

Types

type DeployTestStepRunner

type DeployTestStepRunner struct {
	FixtureName string

	Vars map[string]interface{}

	Canary     int
	ForceBatch bool
	ForceCount bool
}

DeployTestStepRunner implements TestStepRunner to execute a levant deployment

func (DeployTestStepRunner) Run

Run renders the job fixture and triggers a deployment

type TestCase

type TestCase struct {
	// Steps are ran in order stopping on failure
	Steps []TestStep

	// SetupFunc is called at before the steps
	SetupFunc TestStateFunc

	// CleanupFunc is called at the end of the TestCase
	CleanupFunc TestStateFunc
}

TestCase is a single test of levant

type TestState

type TestState struct {
	JobName   string
	Namespace string
	Nomad     *nomad.Client
}

TestState is the configuration for the TestCase

type TestStateFunc

type TestStateFunc func(*TestState) error

TestStateFunc is used to verify acceptance test criteria

func CheckDeploymentStatus

func CheckDeploymentStatus(status string) TestStateFunc

CheckDeploymentStatus is a TestStateFunc to check if the latest deployment of the TestCase job matches the desired status

func CheckTaskGroupCount

func CheckTaskGroupCount(groupName string, count int) TestStateFunc

CheckTaskGroupCount is a TestStateFunc to check a TaskGroup count

type TestStep

type TestStep struct {
	// Runner is used to execute the step, can be nil for a check only step
	Runner TestStepRunner

	// Check is called after Runner if it does not fail
	Check TestStateFunc

	// ExpectErr allows Runner to fail, use CheckErr to confirm error is correct
	ExpectErr bool

	// CheckErr is called if Runner fails and ExpectErr is true
	CheckErr func(error) bool
}

TestStep is a single step within a TestCase

type TestStepRunner

type TestStepRunner interface {
	// Run executes the levant feature under testing
	Run(*TestState) error
}

TestStepRunner models a runner for a TestStep

Jump to

Keyboard shortcuts

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