MCPcopy
hub / github.com/opentofu/opentofu / TestExpandedVariables

Function TestExpandedVariables

internal/lang/blocktoattr/variables_test.go:20–205  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

18)
19
20func TestExpandedVariables(t *testing.T) {
21 fooSchema := &configschema.Block{
22 Attributes: map[string]*configschema.Attribute{
23 "foo": {
24 Type: cty.List(cty.Object(map[string]cty.Type{
25 "bar": cty.String,
26 })),
27 Optional: true,
28 },
29 "bar": {
30 Type: cty.Map(cty.String),
31 Optional: true,
32 },
33 },
34 }
35
36 tests := map[string]struct {
37 src string
38 json bool
39 schema *configschema.Block
40 want []hcl.Traversal
41 }{
42 "empty": {
43 src: ``,
44 schema: &configschema.Block{},
45 want: nil,
46 },
47 "attribute syntax": {
48 src: `
49foo = [
50 {
51 bar = baz
52 },
53]
54`,
55 schema: fooSchema,
56 want: []hcl.Traversal{
57 {
58 hcl.TraverseRoot{
59 Name: "baz",
60 SrcRange: hcl.Range{
61 Filename: "test.tf",
62 Start: hcl.Pos{Line: 4, Column: 11, Byte: 23},
63 End: hcl.Pos{Line: 4, Column: 14, Byte: 26},
64 },
65 },
66 },
67 },
68 },
69 "block syntax": {
70 src: `
71foo {
72 bar = baz
73}
74`,
75 schema: fooSchema,
76 want: []hcl.Traversal{
77 {

Callers

nothing calls this directly

Calls 9

HasErrorsMethod · 0.95
ExpandedVariablesFunction · 0.85
ObjectMethod · 0.80
MapMethod · 0.80
RunMethod · 0.65
EqualMethod · 0.65
DiffMethod · 0.65
ListMethod · 0.45
ParseMethod · 0.45

Tested by

no test coverage detected