assert

package
v0.94.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertThat

AssertThat should be used for "Check:" input in resource.TestStep instead of e.g. resource.ComposeTestCheckFunc. It allows performing all the checks implementing the TestCheckFuncProvider interface.

func AssertThatImport

AssertThatImport should be used for "ImportStateCheck:" input in resource.TestStep instead of e.g. importchecks.ComposeImportStateCheck. It allows performing all the checks implementing the ImportStateCheckFuncProvider interface.

func AssertThatObject

func AssertThatObject(t *testing.T, objectAssert InPlaceAssertionVerifier)

AssertThatObject should be used in the SDK tests for created object validation. It verifies all the prepared assertions in place.

Types

type ImportStateCheckFuncProvider

type ImportStateCheckFuncProvider interface {
	ToTerraformImportStateCheckFunc(t *testing.T) resource.ImportStateCheckFunc
}

ImportStateCheckFuncProvider is an interface with just one method providing resource.ImportStateCheckFunc. It allows using it as input the "ImportStateCheck:" in resource.TestStep for import tests. It should be used with AssertThatImport.

func CheckImport

CheckImport allows using the basic terraform import checks while using AssertThatImport. To use, just simply wrap the check in CheckImport.

type InPlaceAssertionVerifier

type InPlaceAssertionVerifier interface {
	VerifyAll(t *testing.T)
}

InPlaceAssertionVerifier is an interface providing a method allowing verifying all the prepared assertions in place. It does not return function like TestCheckFuncProvider or ImportStateCheckFuncProvider; it runs all the assertions in place instead.

type ResourceAssert

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

ResourceAssert is an embeddable struct that should be used to construct new resource assertions (for resource, show output, parameters, etc.). It implements both TestCheckFuncProvider and ImportStateCheckFuncProvider which makes it easy to create new resource assertions.

func NewImportedResourceAssert

func NewImportedResourceAssert(id string, prefix string) *ResourceAssert

NewImportedResourceAssert creates a ResourceAssert where the resource id should be used as a key for assertions.

func NewResourceAssert

func NewResourceAssert(name string, prefix string) *ResourceAssert

NewResourceAssert creates a ResourceAssert where the resource name should be used as a key for assertions.

func (*ResourceAssert) AddAssertion

func (r *ResourceAssert) AddAssertion(assertion ResourceAssertion)

func (*ResourceAssert) ToTerraformImportStateCheckFunc

func (r *ResourceAssert) ToTerraformImportStateCheckFunc(t *testing.T) resource.ImportStateCheckFunc

ToTerraformImportStateCheckFunc implements ImportStateCheckFuncProvider to allow easier creation of new resource assertions. It goes through all the assertion accumulated earlier and gathers the results of the checks.

func (*ResourceAssert) ToTerraformTestCheckFunc

func (r *ResourceAssert) ToTerraformTestCheckFunc(t *testing.T) resource.TestCheckFunc

ToTerraformTestCheckFunc implements TestCheckFuncProvider to allow easier creation of new resource assertions. It goes through all the assertion accumulated earlier and gathers the results of the checks.

type ResourceAssertion

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

func ResourceParameterBoolValueSet

func ResourceParameterBoolValueSet[T ~string](parameterName T, expected bool) ResourceAssertion

func ResourceParameterIntValueSet

func ResourceParameterIntValueSet[T ~string](parameterName T, expected int) ResourceAssertion

func ResourceParameterLevelSet

func ResourceParameterLevelSet[T ~string](parameterName T, parameterType sdk.ParameterType) ResourceAssertion

func ResourceParameterStringUnderlyingValueSet

func ResourceParameterStringUnderlyingValueSet[T ~string, U ~string](parameterName T, expected U) ResourceAssertion

func ResourceParameterValueSet

func ResourceParameterValueSet[T ~string](parameterName T, expected string) ResourceAssertion

func ResourceShowOutputBoolValueSet

func ResourceShowOutputBoolValueSet(fieldName string, expected bool) ResourceAssertion

func ResourceShowOutputFloatValueSet

func ResourceShowOutputFloatValueSet(fieldName string, expected float64) ResourceAssertion

func ResourceShowOutputIntValueSet

func ResourceShowOutputIntValueSet(fieldName string, expected int) ResourceAssertion

func ResourceShowOutputStringUnderlyingValueSet

func ResourceShowOutputStringUnderlyingValueSet[U ~string](fieldName string, expected U) ResourceAssertion

func ResourceShowOutputValueSet

func ResourceShowOutputValueSet(fieldName string, expected string) ResourceAssertion

func ValueNotSet

func ValueNotSet(fieldName string) ResourceAssertion

func ValueSet

func ValueSet(fieldName string, expected string) ResourceAssertion

type SnowflakeObjectAssert

type SnowflakeObjectAssert[T any, I sdk.ObjectIdentifier] struct {
	// contains filtered or unexported fields
}

SnowflakeObjectAssert is an embeddable struct that should be used to construct new Snowflake object assertions. It implements both TestCheckFuncProvider and ImportStateCheckFuncProvider which makes it easy to create new resource assertions.

func NewSnowflakeObjectAssertWithObject

func NewSnowflakeObjectAssertWithObject[T any, I sdk.ObjectIdentifier](objectType sdk.ObjectType, id I, object *T) *SnowflakeObjectAssert[T, I]

NewSnowflakeObjectAssertWithObject creates a SnowflakeObjectAssert with object that was already fetched from Snowflake. All the checks are run against the given object.

func NewSnowflakeObjectAssertWithProvider

func NewSnowflakeObjectAssertWithProvider[T any, I sdk.ObjectIdentifier](objectType sdk.ObjectType, id I, provider objectProvider[T, I]) *SnowflakeObjectAssert[T, I]

NewSnowflakeObjectAssertWithProvider creates a SnowflakeObjectAssert with id and the provider. Object to check is lazily fetched from Snowflake when the checks are being run.

func (*SnowflakeObjectAssert[T, I]) AddAssertion

func (s *SnowflakeObjectAssert[T, I]) AddAssertion(assertion assertSdk[*T])

func (*SnowflakeObjectAssert[_, _]) ToTerraformImportStateCheckFunc

func (s *SnowflakeObjectAssert[_, _]) ToTerraformImportStateCheckFunc(t *testing.T) resource.ImportStateCheckFunc

ToTerraformImportStateCheckFunc implements ImportStateCheckFuncProvider to allow easier creation of new Snowflake object assertions. It goes through all the assertion accumulated earlier and gathers the results of the checks.

func (*SnowflakeObjectAssert[_, _]) ToTerraformTestCheckFunc

func (s *SnowflakeObjectAssert[_, _]) ToTerraformTestCheckFunc(t *testing.T) resource.TestCheckFunc

ToTerraformTestCheckFunc implements TestCheckFuncProvider to allow easier creation of new Snowflake object assertions. It goes through all the assertion accumulated earlier and gathers the results of the checks.

func (*SnowflakeObjectAssert[_, _]) VerifyAll

func (s *SnowflakeObjectAssert[_, _]) VerifyAll(t *testing.T)

VerifyAll implements InPlaceAssertionVerifier to allow easier creation of new Snowflake object assertions. It verifies all the assertions accumulated earlier and gathers the results of the checks.

type SnowflakeParameterAssertion

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

func SnowflakeParameterBoolValueSet

func SnowflakeParameterBoolValueSet[T ~string](parameterName T, expected bool) SnowflakeParameterAssertion

func SnowflakeParameterDefaultValueOnLevelSet

func SnowflakeParameterDefaultValueOnLevelSet[T ~string](parameterName T, parameterType sdk.ParameterType) SnowflakeParameterAssertion

func SnowflakeParameterDefaultValueSet

func SnowflakeParameterDefaultValueSet[T ~string](parameterName T) SnowflakeParameterAssertion

func SnowflakeParameterIntValueSet

func SnowflakeParameterIntValueSet[T ~string](parameterName T, expected int) SnowflakeParameterAssertion

func SnowflakeParameterLevelSet

func SnowflakeParameterLevelSet[T ~string](parameterName T, parameterType sdk.ParameterType) SnowflakeParameterAssertion

func SnowflakeParameterStringUnderlyingValueSet

func SnowflakeParameterStringUnderlyingValueSet[T ~string, U ~string](parameterName T, expected U) SnowflakeParameterAssertion

func SnowflakeParameterValueSet

func SnowflakeParameterValueSet[T ~string](parameterName T, expected string) SnowflakeParameterAssertion

type SnowflakeParametersAssert

type SnowflakeParametersAssert[I sdk.ObjectIdentifier] struct {
	// contains filtered or unexported fields
}

SnowflakeParametersAssert is an embeddable struct that should be used to construct new Snowflake parameters assertions. It implements both TestCheckFuncProvider and ImportStateCheckFuncProvider which makes it easy to create new resource assertions.

func NewSnowflakeParametersAssertWithParameters

func NewSnowflakeParametersAssertWithParameters[I sdk.ObjectIdentifier](id I, objectType sdk.ObjectType, parameters []*sdk.Parameter) *SnowflakeParametersAssert[I]

NewSnowflakeParametersAssertWithParameters creates a SnowflakeParametersAssert with parameters already fetched from Snowflake. All the checks are run against the given set of parameters.

func NewSnowflakeParametersAssertWithProvider

func NewSnowflakeParametersAssertWithProvider[I sdk.ObjectIdentifier](id I, objectType sdk.ObjectType, provider parametersProvider[I]) *SnowflakeParametersAssert[I]

NewSnowflakeParametersAssertWithProvider creates a SnowflakeParametersAssert with id and the provider. Object to check is lazily fetched from Snowflake when the checks are being run.

func (*SnowflakeParametersAssert[I]) AddAssertion

func (s *SnowflakeParametersAssert[I]) AddAssertion(assertion SnowflakeParameterAssertion)

func (*SnowflakeParametersAssert[_]) ToTerraformImportStateCheckFunc

func (s *SnowflakeParametersAssert[_]) ToTerraformImportStateCheckFunc(t *testing.T) resource.ImportStateCheckFunc

ToTerraformImportStateCheckFunc implements ImportStateCheckFuncProvider to allow easier creation of new Snowflake object parameters assertions. It goes through all the assertion accumulated earlier and gathers the results of the checks.

func (*SnowflakeParametersAssert[_]) ToTerraformTestCheckFunc

func (s *SnowflakeParametersAssert[_]) ToTerraformTestCheckFunc(t *testing.T) resource.TestCheckFunc

ToTerraformTestCheckFunc implements TestCheckFuncProvider to allow easier creation of new Snowflake object parameters assertions. It goes through all the assertion accumulated earlier and gathers the results of the checks.

func (*SnowflakeParametersAssert[_]) VerifyAll

func (s *SnowflakeParametersAssert[_]) VerifyAll(t *testing.T)

VerifyAll implements InPlaceAssertionVerifier to allow easier creation of new Snowflake parameters assertions. It verifies all the assertions accumulated earlier and gathers the results of the checks.

type TestCheckFuncProvider

type TestCheckFuncProvider interface {
	ToTerraformTestCheckFunc(t *testing.T) resource.TestCheckFunc
}

TestCheckFuncProvider is an interface with just one method providing resource.TestCheckFunc. It allows using it as input the "Check:" in resource.TestStep. It should be used with AssertThat.

func Check

Check allows using the basic terraform checks while using AssertThat. To use, just simply wrap the check in Check.

Jump to

Keyboard shortcuts

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