tftest

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TerraformPluginCacheDir = "/tmp/tftest/plugin_cache"

TerraformPluginCacheDir is where the plugins we download are kept. See InitCache() (called on boot) and CleanCache(). You can also override it before calling anything to move it if it's a problem.

Functions

func CleanCache

func CleanCache()

CleanCache cleans our plugin cache by removing it. Put this in TestMain in your tests.

func InitCache added in v0.1.1

func InitCache()

InitCache creates the cache directory. It does not care about errors.

Types

type Harness

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

Harness is the entrypoint into the tftest system

func New

func New(t *testing.T) *Harness

New creates a new tftest harness

func (*Harness) Apply

func (h *Harness) Apply(planfile string)

Apply the harness and resources with terraform. Apply additionally sets up a Cleanup hook to teardown the environment when the test tears down, and parses the state (see State()).

The cleanup hook is not installed when NO_CLEANUP=1 is set in the environment.

func (*Harness) Destroy

func (h *Harness) Destroy()

Destroy the harness and resources with terraform. Discard this struct after calling this method.

func (*Harness) HandleSignals

func (h *Harness) HandleSignals(forward bool)

HandleSignals handles SIGINT and SIGTERM to ensure that containers get cleaned up. It is expected that no other signal handler will be installed afterwards. If the forward argument is true, it will forward the signal back to its own process after deregistering itself as the signal handler, allowing your test suite to exit gracefully. Set it to false to stay out of your way.

taken from https://github.com/erikh/duct

func (*Harness) PlanDir

func (h *Harness) PlanDir() string

PlanDir returns the path to the plan and state, which may be useful in certain failure situations.

func (*Harness) Refresh

func (h *Harness) Refresh()

Refresh applies terraform update to an existing tftest plandir.

func (*Harness) State

func (h *Harness) State() State

State corresponds to the terraform state. This is ingested on each "apply" step, and will be nil until apply is called the first time.

type State

type State map[string]interface{}

State is the parsed state from terraform apply actions.

Jump to

Keyboard shortcuts

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