Documentation
¶
Index ¶
- func Decode(t *testing.T, spec *dataspec.RootSpec, body string) (v *dataspec.Block, diags diagnostics.Diag)deprecated
- func DecodeAndAssert(t *testing.T, spec *dataspec.RootSpec, body string, dataCtx plugindata.Map, ...) (val *dataspec.Block)deprecated
- func ReencodeCTY(t *testing.T, spec *dataspec.RootSpec, val cty.Value, ...) *dataspec.Blockdeprecated
- type TestBlock
- type TestDecoder
- func (td *TestDecoder) AppendBlock(block *TestBlock) *TestDecoder
- func (td *TestDecoder) AppendBody(body string) *TestDecoder
- func (td *TestDecoder) Decode(asserts ...[]diagtest.Assert) (val *dataspec.Block)
- func (td *TestDecoder) DecodeDiag() (val *dataspec.Block, diags diagnostics.Diag)
- func (td *TestDecoder) DecodeDiagFiles() (val *dataspec.Block, fm map[string]*hcl.File, diags diagnostics.Diag)
- func (td *TestDecoder) SetAttr(name string, value cty.Value) *TestDecoder
- func (td *TestDecoder) SetHeaders(typeName string, labels ...string) *TestDecoder
- func (td *TestDecoder) WithContext(ctx context.Context) *TestDecoder
- func (td *TestDecoder) WithDataCtx(dataCtx plugindata.Map) *TestDecoder
- func (td *TestDecoder) WithEvalCtx(evalCtx *hcl.EvalContext) *TestDecoder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 (*TestBlock) AppendBlock ¶
AppendBlock appends a block to the body.
func (*TestBlock) AppendBody ¶
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.