ops

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: MIT Imports: 7 Imported by: 0

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

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

func (o Operative) ContainsString(expected string) *testerror.Error

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

func (o Operative) DoesNotExist() *testerror.Error

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

func (o Operative) Exists() *testerror.Error

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

func (Operative) GetValue

func (o Operative) GetValue() (any, error)

GetValue returns the actual value and a *testerror.Error

func (Operative) HasValue

func (o Operative) HasValue(expected any) *testerror.Error

HasValue returns a non-nil *testerror.Error if the resource does not exist in the plan or if the value of the key does not match the expected value

func (Operative) Query

func (o Operative) Query(query string) Operative

Query executes the provided gjson query on the data in the actual value and overwrites the actual value with the result of the query. https://github.com/tidwall/gjson

Jump to

Keyboard shortcuts

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