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

Function TestVariables

hcldec/variables_test.go:16–215  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestVariables(t *testing.T) {
17 tests := []struct {
18 config string
19 spec Spec
20 want []hcl.Traversal
21 }{
22 {
23 ``,
24 &ObjectSpec{},
25 nil,
26 },
27 {
28 "a = foo\n",
29 &ObjectSpec{},
30 nil, // "a" is not actually used, so "foo" is not required
31 },
32 {
33 "a = foo\n",
34 &AttrSpec{
35 Name: "a",
36 },
37 []hcl.Traversal{
38 {
39 hcl.TraverseRoot{
40 Name: "foo",
41 SrcRange: hcl.Range{
42 Start: hcl.Pos{Line: 1, Column: 5, Byte: 4},
43 End: hcl.Pos{Line: 1, Column: 8, Byte: 7},
44 },
45 },
46 },
47 },
48 },
49 {
50 "a = foo\nb = bar\n",
51 &DefaultSpec{
52 Primary: &AttrSpec{
53 Name: "a",
54 },
55 Default: &AttrSpec{
56 Name: "b",
57 },
58 },
59 []hcl.Traversal{
60 {
61 hcl.TraverseRoot{
62 Name: "foo",
63 SrcRange: hcl.Range{
64 Start: hcl.Pos{Line: 1, Column: 5, Byte: 4},
65 End: hcl.Pos{Line: 1, Column: 8, Byte: 7},
66 },
67 },
68 },
69 {
70 hcl.TraverseRoot{
71 Name: "bar",
72 SrcRange: hcl.Range{
73 Start: hcl.Pos{Line: 2, Column: 5, Byte: 12},

Callers

nothing calls this directly

Calls 4

ParseConfigFunction · 0.92
RunMethod · 0.80
VariablesFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected