Closed fabriziodemaria closed 9 months ago
Hi @fabriziodemaria, sorry for the intromission 😁, first of all, nice catch!! 🥇 Can I suggest you also improve my test file (in TestReplaceNumbers group line ~251) with the following test, to cover your case? If you agree obvs 🙂
Or if you already moved to another task i can create a new PR, as you prefer. Let me know.
t.Run("SuccessfulNestedFlowMap", func(t *testing.T) {
schema := map[string]interface{}{
"structKey": map[string]interface{}{
"structSchema": map[string]interface{}{
"schema": map[string]interface{}{
"nestedStructKey": map[string]interface{}{
"structSchema": map[string]interface{}{
"schema": map[string]interface{}{
"nestedDoubleKey": map[string]interface{}{
"doubleSchema": map[string]interface{}{},
},
},
},
},
},
},
},
}
input := map[string]interface{}{
"structKey": map[string]interface{}{
"nestedStructKey": map[string]interface{}{
"nestedDoubleKey": json.Number("123.45"),
},
},
}
expected := map[string]interface{}{
"structKey": map[string]interface{}{
"nestedStructKey": map[string]interface{}{
"nestedDoubleKey": float64(123.45),
},
},
}
updatedMap, err := replaceNumbers("", input, schema)
assert.NoError(t, err)
assert.Equal(t, expected, updatedMap)
})
@Valkyrie00 your test suggestion sounds great, feel free to open a PR!
Recursive function
replaceNumbers
wouldn't propagate thebasePath
correctly, which causesTYPE_MISMATCH
error