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

Function TestDecode

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

Source from the content-addressed store, hash-verified

14)
15
16func TestDecode(t *testing.T) {
17 tests := []struct {
18 config string
19 spec Spec
20 ctx *hcl.EvalContext
21 want cty.Value
22 diagCount int
23 }{
24 {
25 ``,
26 &ObjectSpec{},
27 nil,
28 cty.EmptyObjectVal,
29 0,
30 },
31 {
32 "a = 1\n",
33 &ObjectSpec{},
34 nil,
35 cty.EmptyObjectVal,
36 1, // attribute named "a" is not expected here
37 },
38 {
39 "a = 1\n",
40 &ObjectSpec{
41 "a": &AttrSpec{
42 Name: "a",
43 Type: cty.Number,
44 },
45 },
46 nil,
47 cty.ObjectVal(map[string]cty.Value{
48 "a": cty.NumberIntVal(1),
49 }),
50 0,
51 },
52 {
53 "a = 1\n",
54 &AttrSpec{
55 Name: "a",
56 Type: cty.Number,
57 },
58 nil,
59 cty.NumberIntVal(1),
60 0,
61 },
62 {
63 "a = 1\n",
64 &DefaultSpec{
65 Primary: &AttrSpec{
66 Name: "a",
67 Type: cty.Number,
68 },
69 Default: &LiteralSpec{
70 Value: cty.NumberIntVal(10),
71 },
72 },
73 nil,

Callers

nothing calls this directly

Calls 5

ParseConfigFunction · 0.92
ObjectMethod · 0.80
RunMethod · 0.80
DecodeFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected