MCPcopy
hub / github.com/hashicorp/hcl / MockExprTraversalSrc

Function MockExprTraversalSrc

hcltest/mock.go:261–267  ·  view source on GitHub ↗

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.

(src string)

Source from the content-addressed store, hash-verified

259// This method is primarily for testing with hard-coded traversal strings, so
260// it will panic if the given string is not syntactically correct.
261func MockExprTraversalSrc(src string) hcl.Expression {
262 traversal, diags := hclsyntax.ParseTraversalAbs([]byte(src), "MockExprTraversal", hcl.Pos{})
263 if diags.HasErrors() {
264 panic("invalid traversal string")
265 }
266 return MockExprTraversal(traversal)
267}
268
269type mockExprTraversal struct {
270 Traversal hcl.Traversal

Callers 4

TestExpandFunction · 0.92
TestExpandUnknownBodiesFunction · 0.92
TestExpandMarkedForEachFunction · 0.92

Calls 3

ParseTraversalAbsFunction · 0.92
MockExprTraversalFunction · 0.85
HasErrorsMethod · 0.80

Tested by 4

TestExpandFunction · 0.74
TestExpandUnknownBodiesFunction · 0.74
TestExpandMarkedForEachFunction · 0.74