Skip to content

Commit

Permalink
decoder: Add failing test for JSON traversal
Browse files Browse the repository at this point in the history
  • Loading branch information
radeksimko committed Mar 22, 2023
1 parent 871393e commit fc1f37e
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions decoder/expr_reference_ref_origins_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,39 @@ func TestCollectRefOrigins_exprReference_json(t *testing.T) {
},
},
},
{ // TODO: HCL misreports range for traversals w/ string keys in JSON (off by 2)
"traversal with string index steps",
map[string]*schema.AttributeSchema{
"attr": {
Constraint: schema.Reference{
OfType: cty.String,
},
IsOptional: true,
},
},
`{"attr": "${one.two[\"key\"].attr[\"foo\"]}"}`,
reference.Origins{
reference.LocalOrigin{
Addr: lang.Address{
lang.RootStep{Name: "one"},
lang.AttrStep{Name: "two"},
lang.IndexStep{Key: cty.StringVal("key")},
lang.AttrStep{Name: "attr"},
lang.IndexStep{Key: cty.StringVal("foo")},
},
Range: hcl.Range{
Filename: "test.tf.json",
Start: hcl.Pos{Line: 1, Column: 13, Byte: 12},
End: hcl.Pos{Line: 1, Column: 32, Byte: 31},
},
Constraints: reference.OriginConstraints{
{
OfType: cty.String,
},
},
},
},
},
}
for i, tc := range testCases {
t.Run(fmt.Sprintf("%d-%s", i, tc.testName), func(t *testing.T) {
Expand Down

0 comments on commit fc1f37e

Please sign in to comment.