plugintest

package
v0.4.3-final-apache Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode deprecated

func Decode(t *testing.T, spec *dataspec.RootSpec, body string) (v *dataspec.Block, diags diagnostics.Diag)

Deprecated: use plugintest.NewTestDecoder

func DecodeAndAssert deprecated

func DecodeAndAssert(t *testing.T, spec *dataspec.RootSpec, body string, dataCtx plugindata.Map, asserts diagtest.Asserts) (val *dataspec.Block)

Decodes a string (representing content of a config/data/content block) into cty.Value according to given spec (i.e. respecting default values)

Deprecated: use plugintest.NewTestDecoder

func ReencodeCTY deprecated

func ReencodeCTY(t *testing.T, spec *dataspec.RootSpec, val cty.Value, asserts [][]diagtest.Assert) *dataspec.Block

We have a massive amount of tests that break as soon as we add schemas with default values. This function is a workaround. It reencodes provided cty.Value to hcl text and then re-parses that text in accordance to spec. Ugly hack, but there's over a 100 tests in need of a rewrite that can't be automated with regex or similar.

Deprecated: use plugintest.NewTestDecoder

Types

type TestBlock

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

func NewTestBlock

func NewTestBlock(typeName string, labels ...string) *TestBlock

func (*TestBlock) AppendBlock

func (tb *TestBlock) AppendBlock(block *TestBlock) *TestBlock

AppendBlock appends a block to the body.

func (*TestBlock) AppendBody

func (tb *TestBlock) AppendBody(body string) *TestBlock

func (*TestBlock) SetAttr

func (tb *TestBlock) SetAttr(name string, value cty.Value) *TestBlock

SetAttr sets the attribute value.

func (*TestBlock) SetHeaders

func (tb *TestBlock) SetHeaders(typeName string, labels ...string) *TestBlock

SetHeaders sets the block type and labels.

type TestDecoder

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

TestDecoder is a helper for testing block decoding.

func NewTestDecoder

func NewTestDecoder(t *testing.T, spec *dataspec.RootSpec) *TestDecoder

NewTestDecoder creates a new TestDecoder. This is the preferred way to create the data for testing plugins.

func (*TestDecoder) AppendBlock

func (td *TestDecoder) AppendBlock(block *TestBlock) *TestDecoder

func (*TestDecoder) AppendBody

func (td *TestDecoder) AppendBody(body string) *TestDecoder

func (*TestDecoder) Decode

func (td *TestDecoder) Decode(asserts ...[]diagtest.Assert) (val *dataspec.Block)

Decode decodes the block and asserts diagnostics.

func (*TestDecoder) DecodeDiag

func (td *TestDecoder) DecodeDiag() (val *dataspec.Block, diags diagnostics.Diag)

Decodes the block and returns diagnostics.

func (*TestDecoder) DecodeDiagFiles

func (td *TestDecoder) DecodeDiagFiles() (val *dataspec.Block, fm map[string]*hcl.File, diags diagnostics.Diag)

func (*TestDecoder) SetAttr

func (td *TestDecoder) SetAttr(name string, value cty.Value) *TestDecoder

func (*TestDecoder) SetHeaders

func (td *TestDecoder) SetHeaders(typeName string, labels ...string) *TestDecoder

func (*TestDecoder) WithContext

func (td *TestDecoder) WithContext(ctx context.Context) *TestDecoder

WithContext sets the context.

func (*TestDecoder) WithDataCtx

func (td *TestDecoder) WithDataCtx(dataCtx plugindata.Map) *TestDecoder

WithDataCtx sets the data context.

func (*TestDecoder) WithEvalCtx

func (td *TestDecoder) WithEvalCtx(evalCtx *hcl.EvalContext) *TestDecoder

WithEvalCtx sets the evaluation context.

Jump to

Keyboard shortcuts

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