config

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: MPL-2.0 Imports: 7 Imported by: 1

Documentation

Overview

Package config implements functionality for supporting native Terraform configuration and variables for testing purposes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolVariable

func BoolVariable(value bool) boolVariable

BoolVariable returns boolVariable which implements Variable.

func FloatVariable

func FloatVariable[T anyFloat](value T) floatVariable

FloatVariable returns floatVariable which implements Variable.

func IntegerVariable

func IntegerVariable[T anyInteger](value T) integerVariable

IntegerVariable returns integerVariable which implements Variable.

func ListVariable

func ListVariable(value ...Variable) listVariable

ListVariable returns listVariable which implements Variable.

func MapVariable

func MapVariable(value map[string]Variable) mapVariable

MapVariable returns mapVariable which implements Variable.

func ObjectVariable

func ObjectVariable(value map[string]Variable) objectVariable

ObjectVariable returns objectVariable which implements Variable.

func SetVariable

func SetVariable(value ...Variable) setVariable

SetVariable returns setVariable which implements Variable.

func StaticDirectory

func StaticDirectory(directory string) func(TestStepConfigRequest) string

StaticDirectory returns the supplied directory.

func StaticFile

func StaticFile(file string) func(TestStepConfigRequest) string

StaticFile returns the supplied file.

func StringVariable

func StringVariable(value string) stringVariable

StringVariable returns stringVariable which implements Variable.

func TestNameDirectory

func TestNameDirectory() func(TestStepConfigRequest) string

TestNameDirectory returns the name of the test prefixed with "testdata".

For example, given test code:

func TestExampleCloudThing_basic(t *testing.T) {
    resource.Test(t, resource.TestCase{
        Steps: []resource.TestStep{
            {
                ConfigDirectory: config.TestNameDirectory(),
            },
        },
    })
}

The testing configurations will be expected in the testdata/TestExampleCloudThing_basic/ directory.

func TestNameFile

func TestNameFile(file string) func(TestStepConfigRequest) string

TestNameFile returns the name of the test suffixed with the supplied file and prefixed with "testdata".

For example, given test code:

func TestExampleCloudThing_basic(t *testing.T) {
    resource.Test(t, resource.TestCase{
        Steps: []resource.TestStep{
            {
                ConfigFile: config.TestNameFile("test.tf"),
            },
        },
    })
}

The testing configuration will be expected in the testdata/TestExampleCloudThing_basic/test.tf file.

func TestStepDirectory

func TestStepDirectory() func(TestStepConfigRequest) string

TestStepDirectory returns the name of the test suffixed with the test step number and prefixed with "testdata".

For example, given test code:

func TestExampleCloudThing_basic(t *testing.T) {
    resource.Test(t, resource.TestCase{
        Steps: []resource.TestStep{
            {
                ConfigDirectory: config.TestStepDirectory(),
            },
        },
    })
}

The testing configurations will be expected in the testdata/TestExampleCloudThing_basic/1 directory as TestStepConfigRequest.StepNumber is one-based.

func TestStepFile

func TestStepFile(file string) func(TestStepConfigRequest) string

TestStepFile returns the name of the test suffixed with the test step number and the supplied file, and prefixed with "testdata".

For example, given test code:

func TestExampleCloudThing_basic(t *testing.T) {
    resource.Test(t, resource.TestCase{
        Steps: []resource.TestStep{
            {
                ConfigFile: config.TestStepFile("test.tf"),
            },
        },
    })
}

The testing configuration will be expected in the testdata/TestExampleCloudThing_basic/1/test.tf file as TestStepConfigRequest.StepNumber is one-based.

func TupleVariable

func TupleVariable(value ...Variable) tupleVariable

TupleVariable returns tupleVariable which implements Variable.

Types

type TestStepConfigFunc

type TestStepConfigFunc func(TestStepConfigRequest) string

TestStepConfigFunc is the callback type used with acceptance tests to specify a string which either identifies a directory containing Terraform configuration files, or a file that contains Terraform configuration.

func (TestStepConfigFunc) Exec

Exec executes TestStepConfigFunc if it is not nil, otherwise an empty string is returned.

type TestStepConfigRequest

type TestStepConfigRequest struct {
	StepNumber int
	TestName   string
}

TestStepConfigRequest defines the request supplied to types implementing TestStepConfigFunc. StepNumber is one-based and is used in the predefined helper functions:

TestName is used in the predefined helper functions:

type Variable

type Variable interface {
	json.Marshaler
}

Variable interface is an alias to json.Marshaler.

type Variables

type Variables map[string]Variable

Variables is a type holding a key-value map of variable names to types implementing the Variable interface.

func (Variables) Write

func (v Variables) Write(dest string) error

Write creates a file in the destination supplied containing JSON encoded Variables.

Jump to

Keyboard shortcuts

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