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)
| 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. |
| 261 | func 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 | |
| 269 | type mockExprTraversal struct { |
| 270 | Traversal hcl.Traversal |