Documentation ¶
Overview ¶
Package hcltest contains utilities that aim to make it more convenient to write tests for code that interacts with the HCL API.
This package is intended for use only in test code. It is optimized for convenience of use over all other concerns.
Index ¶
- func MockAttrs(exprs map[string]hcl.Expression) hcl.Attributes
- func MockBody(content *hcl.BodyContent) hcl.Body
- func MockExprList(exprs []hcl.Expression) hcl.Expression
- func MockExprLiteral(val cty.Value) hcl.Expression
- func MockExprTraversal(traversal hcl.Traversal) hcl.Expression
- func MockExprTraversalSrc(src string) hcl.Expression
- func MockExprVariable(name string) hcl.Expression
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MockAttrs ¶
func MockAttrs(exprs map[string]hcl.Expression) hcl.Attributes
MockAttrs constructs and returns a hcl.Attributes map with attributes derived from the given expression map.
Each entry in the map becomes an attribute whose name is the key and whose expression is the value.
func MockBody ¶
func MockBody(content *hcl.BodyContent) hcl.Body
MockBody returns a hcl.Body implementation that works in terms of a caller-constructed hcl.BodyContent, thus avoiding the need to parse a "real" HCL config file to use as input to a test.
func MockExprList ¶
func MockExprList(exprs []hcl.Expression) hcl.Expression
func MockExprLiteral ¶
MockExprLiteral returns a hcl.Expression that evaluates to the given literal value.
func MockExprTraversal ¶
func MockExprTraversal(traversal hcl.Traversal) hcl.Expression
MockExprTraversal returns a hcl.Expression that evaluates the given absolute traversal.
func MockExprTraversalSrc ¶
func MockExprTraversalSrc(src string) hcl.Expression
MockExprTraversalSrc is like MockExprTraversal except it takes a traversal string as defined by the native syntax and parses it first.
This method is primarily for testing with hard-coded traversal strings, so it will panic if the given string is not syntactically correct.
func MockExprVariable ¶
func MockExprVariable(name string) hcl.Expression
MockExprVariable returns a hcl.Expression that evaluates to the value of the variable with the given name.
Types ¶
This section is empty.