json: test handling of duplicate keys

We want to see in the output when keys are used more than once. This should be
fixed because parsing the log messages as JSON will only preserve one of the
values.
This commit is contained in:
Patrick Ohly 2021-10-26 20:59:04 +02:00
parent ab318cf89f
commit ef30d845d9

View File

@ -65,6 +65,11 @@ func TestZapLoggerInfo(t *testing.T) {
names: []string{"hello", "world"},
format: "{\"ts\":%f,\"logger\":\"hello.world\",\"caller\":\"json/json_test.go:%d\",\"msg\":\"test for WithName\",\"v\":0}\n",
},
{
msg: "test for duplicate keys",
format: "{\"ts\":%f,\"caller\":\"json/json_test.go:%d\",\"msg\":\"test for duplicate keys\",\"v\":0,\"akey\":\"avalue\",\"akey\":\"anothervalue\"}\n",
keysValues: []interface{}{"akey", "avalue", "akey", "anothervalue"},
},
}
for _, data := range testDataInfo {