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

Function TestApplyPath

ops_test.go:13–392  ·  ops_test.go::TestApplyPath
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestApplyPath(t *testing.T) {
14 tests := []struct {
15 Start cty.Value
16 Path cty.Path
17 Want cty.Value
18 WantErr string
19 }{
20 {
21 cty.StringVal("hello"),
22 nil,
23 cty.StringVal("hello"),
24 ``,
25 },
26 {
27 cty.StringVal("hello"),
28 (cty.Path)(nil).Index(cty.StringVal("boop")),
29 cty.NilVal,
30 `Invalid index: This value does not have any indices.`,
31 },
32 {
33 cty.StringVal("hello"),
34 (cty.Path)(nil).Index(cty.NumberIntVal(0)),
35 cty.NilVal,
36 `Invalid index: This value does not have any indices.`,
37 },
38 {
39 cty.ListVal([]cty.Value{
40 cty.StringVal("hello"),
41 }),
42 (cty.Path)(nil).Index(cty.NumberIntVal(0)),
43 cty.StringVal("hello"),
44 ``,
45 },
46 {
47 cty.ListVal([]cty.Value{
48 cty.StringVal("hello"),
49 }).Mark("x"),
50 (cty.Path)(nil).Index(cty.NumberIntVal(0)),
51 cty.StringVal("hello").Mark("x"),
52 ``,
53 },
54 {
55 cty.TupleVal([]cty.Value{
56 cty.StringVal("hello"),
57 }),
58 (cty.Path)(nil).Index(cty.NumberIntVal(0)),
59 cty.StringVal("hello"),
60 ``,
61 },
62 {
63 cty.MapVal(map[string]cty.Value{
64 "a": cty.StringVal("foo").Mark("x"),
65 "b": cty.StringVal("bar").Mark("x"),
66 }).Mark("x"),
67 cty.GetAttrPath("a"),
68 cty.StringVal("foo").Mark("x"),
69 ``,
70 },

Callers

nothing calls this directly

Calls 6

ApplyPathFunction · 0.85
ListMethod · 0.80
ObjectMethod · 0.80
RunMethod · 0.80
HasErrorsMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected