Documentation
¶
Overview ¶
Package ops contains the operations that can be performed on the data extracted from the plan, output, or state. E.g. HasValue, Exists, DoesNotExist, etc. Using a separate package means we can test planned values, outputs and anything else. It is also possible to query the data using gjson queries. This will return a ops.Operative type which can be used to compare the data.
Index ¶
- type JsonAssertionFunc
- type Operative
- func (o Operative) ContainsJsonValue(assertion JsonAssertionFunc) *testerror.Error
- func (o Operative) ContainsString(expected string) *testerror.Error
- func (o Operative) DoesNotExist() *testerror.Error
- func (o Operative) Exists() *testerror.Error
- func (o Operative) GetValue() (any, error)
- func (o Operative) HasValue(expected any) *testerror.Error
- func (o Operative) Query(query string) Operative
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JsonAssertionFunc ¶
type JsonAssertionFunc func(input json.RawMessage) (*bool, error)
JsonAssertionFunc is a function which can be used to unmarshal a raw JSON message and check its contents.
type Operative ¶
type Operative struct { Reference string Actual any Exist bool // contains filtered or unexported fields }
Operative is a type which can be used to compare the expected and actual values of a given combination
func (Operative) ContainsJsonValue ¶
func (o Operative) ContainsJsonValue(assertion JsonAssertionFunc) *testerror.Error
ContainsJsonValue returns a *testerror.Error which asserts upon a given JSON string set by deserializing it and then asserting on it via the JsonAssertionFunc.
func (Operative) ContainsString ¶
ContainsString returns a non-nil *testerror.Error if the resource does not exist in the plan or if the value of the key does not contain the expected string
func (Operative) DoesNotExist ¶
DoesNotExist returns a non-nil *testerror.Error if the resource does not exist in the plan or if the key exists in the resource
func (Operative) Exists ¶
Exists returns a non-nil *testerror.Error if the resource does not exist in the plan or if the key does not exist in the resource