Skip to content

Commit

Permalink
Fix fixture param index bug (#1140)
Browse files Browse the repository at this point in the history
  • Loading branch information
vcheung-stripe authored Jan 23, 2024
1 parent b07a577 commit be3b0b3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/parsers/parsers.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func ParseMap(params map[string]interface{}, parent string, index int, queryResp
case reflect.Map:
m := value.(map[string]interface{})

result, err := ParseMap(m, keyname, index, queryRespMap)
result, err := ParseMap(m, keyname, -1, queryRespMap)

if err != nil {
return make([]string, 0), err
Expand Down
22 changes: 22 additions & 0 deletions pkg/parsers/parsers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,28 @@ func TestParseInterfaceFromRaw(t *testing.T) {
require.Equal(t, output[1], "salary=1000000000")
}

func TestParseInterfaceDeeplyNested(t *testing.T) {
label := make(map[string]interface{})
label["custom"] = "First Name"
label["type"] = "custom"

customField := make(map[string]interface{})
customField["label"] = label

customFields := make([]interface{}, 1)
customFields[0] = customField

data := make(map[string]interface{})
data["custom_fields"] = customFields

output, _ := ParseInterface(data, make(map[string]gjson.Result))
sort.Strings(output)

require.Equal(t, 2, len(output))
require.Equal(t, "custom_fields[0][label][custom]=First Name", output[0])
require.Equal(t, "custom_fields[0][label][type]=custom", output[1])
}

func TestParseInterface(t *testing.T) {
address := make(map[string]interface{})
address["line1"] = "1 Planet Express St"
Expand Down

0 comments on commit be3b0b3

Please sign in to comment.