scenario

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ShouldContain = iota
	ShouldNOTContain
	ShouldBeEqual
)
View Source
const DefaultPlanOutput = "plan.out"

Variables

This section is empty.

Functions

func GetTerraformDir added in v0.0.6

func GetTerraformDir(t *testing.T, path string, isParallel bool) (string, error)

GetTerraformDir returns the Terraform directory path. It's used to get the Terraform directory path for the scenario. If the scenario is running in parallel, it sets up the Terraform directory for parallelism.

func SetupTerraformDirForParallelism added in v0.0.6

func SetupTerraformDirForParallelism(t *testing.T, tfDir string) (string, error)

SetupTerraformDirForParallelism sets up the Terraform directory for parallelism. It copies the Terraform directory to a temporary directory and returns the path to the temporary directory.

Types

type Client

type Client struct {

	// Stg is the StageClient
	Stg *StageClient
	// contains filtered or unexported fields
}

func New

func New(t *testing.T, workdir string) (*Client, error)

New creates a new Terraform options with default retryable errors and saves it to the workdir This is a wrapper around terraform.WithDefaultRetryableErrors

func NewWithOptions

func NewWithOptions(t *testing.T, workdir string, opts ...OptFn) (*Client, error)

func (*Client) GetAWS

func (c *Client) GetAWS() cloudprovider.AWSAdapter

func (*Client) GetTerraformOptions

func (c *Client) GetTerraformOptions() *terraform.Options

type Config

type Config interface {
	GetTerraformOptions() *terraform.Options
	GetAWS() cloudprovider.AWSAdapter
}

type JSONPathTestCases added in v0.0.11

type JSONPathTestCases struct {
	TestName           string
	ExpectedValue      interface{}
	JSONPathToCompare  string
	AllowDifferentType bool
	TestType           TestType
}

type OptFn

type OptFn func(*Options) error

func WithAWS

func WithAWS(region string) OptFn

func WithParallel added in v0.0.6

func WithParallel() OptFn

func WithRetry added in v0.0.7

func WithRetry(retryableErrors map[string]string, timeBetweenRetries time.Duration, maxRetries int) OptFn

func WithScannedTFVars added in v0.0.8

func WithScannedTFVars(workdir, fixturesDir string) OptFn

func WithVarFiles

func WithVarFiles(workdir string, varFiles ...string) OptFn

func WithVars

func WithVars(vars map[string]interface{}) OptFn

type Options

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

type Stage

type Stage interface {
	DestroyStage(t *testing.T, options *terraform.Options)
	PlanStage(t *testing.T, options *terraform.Options)
	ApplyStage(t *testing.T, options *terraform.Options)
	PlanStageWithExpectedChanges(t *testing.T, options *terraform.Options, expectedChanges int)
	PlanStageWithDetailedExpectedChanges(t *testing.T, options *terraform.Options, expectedAdds, expectedDeletes, expectedUpdates int)
	PlanStageWithAnySortOfChanges(t *testing.T, options *terraform.Options)
	PlanStageExpectedNoChanges(t *testing.T, options *terraform.Options)
	PlanWithSpecificResourcesThatWillChange(t *testing.T, options *terraform.Options, resources []string)
	PlanWithResourcesExpectedToBeCreated(t *testing.T, options *terraform.Options, resources []string)
	PlanWithResourcesExpectedToBeDeleted(t *testing.T, options *terraform.Options, resources []string)
	PlanWithResourcesExpectedToBeUpdated(t *testing.T, options *terraform.Options, resources []string)
	PlanWithSpecificVariableValueToExpect(t *testing.T, options *terraform.Options, variable, value string)
	PlanAndAssertJSONWithJSONPath(t *testing.T, options *terraform.Options, testCases []JSONPathTestCases)
}

type StageClient

type StageClient struct{}

func (*StageClient) ApplyStage

func (c *StageClient) ApplyStage(t *testing.T, options *terraform.Options)

func (*StageClient) CheckResourcesChanges

func (c *StageClient) CheckResourcesChanges(t *testing.T, options *terraform.Options, resources []string, check func(tfjson.Actions) bool, failMsg string)

CheckResourcesChanges checks if the specified resources have the expected changes The check function is used to determine if the resource has the expected change

func (*StageClient) DestroyStage

func (c *StageClient) DestroyStage(t *testing.T, options *terraform.Options)

func (*StageClient) PlanAndAssertJSONWithJSONPath added in v0.0.11

func (c *StageClient) PlanAndAssertJSONWithJSONPath(t *testing.T, options *terraform.Options, testCases []JSONPathTestCases)

PlanAndAssertJSONWithJSONPath performs JSON path planning and assertion in Go testing.

t *testing.T: Testing object options *terraform.Options: Terraform options testCases []JSONPathTestCases: Array of JSON path test cases

func (*StageClient) PlanStage

func (c *StageClient) PlanStage(t *testing.T, options *terraform.Options)

func (*StageClient) PlanStageExpectedNoChanges

func (c *StageClient) PlanStageExpectedNoChanges(t *testing.T, options *terraform.Options)

func (*StageClient) PlanStageWithAnySortOfChanges

func (c *StageClient) PlanStageWithAnySortOfChanges(t *testing.T, options *terraform.Options)

func (*StageClient) PlanStageWithDetailedExpectedChanges

func (c *StageClient) PlanStageWithDetailedExpectedChanges(t *testing.T, options *terraform.Options, expectedAdds, expectedDeletes, expectedUpdates int)

func (*StageClient) PlanStageWithExpectedChanges

func (c *StageClient) PlanStageWithExpectedChanges(t *testing.T, options *terraform.Options, expectedChanges int)

func (*StageClient) PlanWithResourcesExpectedToBeCreated

func (c *StageClient) PlanWithResourcesExpectedToBeCreated(t *testing.T, options *terraform.Options, resources []string)

func (*StageClient) PlanWithResourcesExpectedToBeDeleted

func (c *StageClient) PlanWithResourcesExpectedToBeDeleted(t *testing.T, options *terraform.Options, resources []string)

func (*StageClient) PlanWithResourcesExpectedToBeUpdated

func (c *StageClient) PlanWithResourcesExpectedToBeUpdated(t *testing.T, options *terraform.Options, resources []string)

func (*StageClient) PlanWithSpecificResourcesThatWillChange

func (c *StageClient) PlanWithSpecificResourcesThatWillChange(t *testing.T, options *terraform.Options, resources []string)

func (*StageClient) PlanWithSpecificVariableValueToExpect

func (c *StageClient) PlanWithSpecificVariableValueToExpect(t *testing.T, options *terraform.Options, variable, expectedValue string)

type TestType added in v0.0.11

type TestType int

Jump to

Keyboard shortcuts

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