terraform

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package terraform provides a test harness for tf2pulumi. It is a thin wrapper on top of the Pulumi CLI's integration test framework while supplying a "compile step" for Terraform code that we'll then convert to Pulumi code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunTest added in v0.4.9

func RunTest(t *testing.T, dir string, opts ...TestOptionsFunc)

RunTest defines a new test case residing in the given directory. It takes zero or more options which can be used to further configure the test harness.

Types

type ConvertOptions added in v0.4.9

type ConvertOptions struct {
	Compile    *bool  // If true, run pulumi on the generated code. Defaults to true.
	FilterName string // If non-empty, filter out properties with the given name.
	Skip       string // If non-empty, skip the current test with the given message.
}

ConvertOptions are options controlling the behavior of tf2pulumi. Its arguments are generally converted to command-line flags.

func (ConvertOptions) With added in v0.4.9

With constructs a new ConvertOptions out of a base set of options and a set of options that will override fields that are not set in the base.

type Test added in v0.4.9

type Test struct {
	ProjectName string
	Options     ConvertOptions                  // Base options for tf2pulumi, inherited by all targets.
	RunOptions  *integration.ProgramTestOptions // Options for running the generated Pulumi code
	Python      *ConvertOptions                 // Python-specific options overriding the base options
	TypeScript  *ConvertOptions                 // TypeScript-specific options overriding the base options
}

Test represents a single test case. It consists of Terraform input and optionally a "baseline" file that will be diffed against the output of tf2pulumi. Each test case is run on every target unless the target specifically opts out.

func (Test) Run added in v0.4.9

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

Run executes this test, spawning subtests for each supported target.

type TestOptionsFunc added in v0.4.9

type TestOptionsFunc func(*testing.T, *Test)

TestOptionsFunc is a function that can be used as an option to `RunTest`.

func AllowChanges added in v0.7.0

func AllowChanges() TestOptionsFunc

AllowChanges allows changes on the empty preview and update for the given test.

func Compile added in v0.4.9

func Compile(value bool) TestOptionsFunc

Compile sets whether or not this test case should be executed by Pulumi after being processed by tf2pulumi. Defaults to true if not provided.

func FilterName added in v0.4.9

func FilterName(value string) TestOptionsFunc

FilterName sets whether or not tf2pulumi should filter properties with the given name for this test case. Defaults to the empty string, which will cause no properties to be filtered.

func NoParallel added in v0.12.0

func NoParallel() TestOptionsFunc

Sets the NoParallel flag on the test to run

func Python added in v0.4.9

func Python(opts ...TestOptionsFunc) TestOptionsFunc

Python sets up a new context that also accepts any number of test options, but applies those test options only when running with the Python target. Options that affect the Pulumi CLI integration test framework are ignored.

func Skip added in v0.4.9

func Skip(reason string) TestOptionsFunc

Skip skips the test for the given reason.

func SkipPython added in v0.4.9

func SkipPython() TestOptionsFunc

SkipPython skips the Python target for the given test.

func SkipTypeScript added in v0.12.0

func SkipTypeScript(reason string) TestOptionsFunc

SkipTypeScript skips the TypeScript target for the given test.

func TypeScript added in v0.12.0

func TypeScript(opts ...TestOptionsFunc) TestOptionsFunc

TypeScript sets up a new context that also accepts any number of test options, but applies those test options only when running with the TypeScript target. Options that affect the Pulumi CLI integration test framework are ignored.

Jump to

Keyboard shortcuts

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