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

Function TestExpand

ext/dynblock/expand_body_test.go:19–340  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

17)
18
19func TestExpand(t *testing.T) {
20 srcBody := hcltest.MockBody(&hcl.BodyContent{
21 Blocks: hcl.Blocks{
22 {
23 Type: "a",
24 Labels: []string{"static0"},
25 LabelRanges: []hcl.Range{hcl.Range{}},
26 Body: hcltest.MockBody(&hcl.BodyContent{
27 Attributes: hcltest.MockAttrs(map[string]hcl.Expression{
28 "val": hcltest.MockExprLiteral(cty.StringVal("static a 0")),
29 }),
30 }),
31 },
32 {
33 Type: "b",
34 Body: hcltest.MockBody(&hcl.BodyContent{
35 Blocks: hcl.Blocks{
36 {
37 Type: "c",
38 Body: hcltest.MockBody(&hcl.BodyContent{
39 Attributes: hcltest.MockAttrs(map[string]hcl.Expression{
40 "val0": hcltest.MockExprLiteral(cty.StringVal("static c 0")),
41 }),
42 }),
43 },
44 {
45 Type: "dynamic",
46 Labels: []string{"c"},
47 LabelRanges: []hcl.Range{hcl.Range{}},
48 Body: hcltest.MockBody(&hcl.BodyContent{
49 Attributes: hcltest.MockAttrs(map[string]hcl.Expression{
50 "for_each": hcltest.MockExprLiteral(cty.ListVal([]cty.Value{
51 cty.StringVal("dynamic c 0"),
52 cty.StringVal("dynamic c 1"),
53 })),
54 "iterator": hcltest.MockExprVariable("dyn_c"),
55 }),
56 Blocks: hcl.Blocks{
57 {
58 Type: "content",
59 Body: hcltest.MockBody(&hcl.BodyContent{
60 Attributes: hcltest.MockAttrs(map[string]hcl.Expression{
61 "val0": hcltest.MockExprTraversalSrc("dyn_c.value"),
62 }),
63 }),
64 },
65 },
66 }),
67 },
68 },
69 }),
70 },
71 {
72 Type: "dynamic",
73 Labels: []string{"a"},
74 LabelRanges: []hcl.Range{hcl.Range{}},
75 Body: hcltest.MockBody(&hcl.BodyContent{
76 Attributes: hcltest.MockAttrs(map[string]hcl.Expression{

Callers

nothing calls this directly

Calls 10

MockBodyFunction · 0.92
MockAttrsFunction · 0.92
MockExprLiteralFunction · 0.92
MockExprVariableFunction · 0.92
MockExprTraversalSrcFunction · 0.92
MockExprListFunction · 0.92
PartialDecodeFunction · 0.92
DecodeFunction · 0.92
ExpandFunction · 0.85
RunMethod · 0.80

Tested by

no test coverage detected