eventmanager: fix params copy
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
parent
f03fdd1155
commit
6395fa0b67
2 changed files with 11 additions and 0 deletions
|
@ -584,6 +584,13 @@ func (p *EventParams) getACopy() *EventParams {
|
||||||
}
|
}
|
||||||
params.IDPCustomFields = &fields
|
params.IDPCustomFields = &fields
|
||||||
}
|
}
|
||||||
|
if len(params.Metadata) > 0 {
|
||||||
|
metadata := make(map[string]string)
|
||||||
|
for k, v := range p.Metadata {
|
||||||
|
metadata[k] = v
|
||||||
|
}
|
||||||
|
params.Metadata = metadata
|
||||||
|
}
|
||||||
|
|
||||||
return ¶ms
|
return ¶ms
|
||||||
}
|
}
|
||||||
|
|
|
@ -2056,6 +2056,10 @@ func TestEventParamsCopy(t *testing.T) {
|
||||||
assert.Equal(t, params.IDPCustomFields, paramsCopy.IDPCustomFields)
|
assert.Equal(t, params.IDPCustomFields, paramsCopy.IDPCustomFields)
|
||||||
(*paramsCopy.IDPCustomFields)["field1"] = "val2"
|
(*paramsCopy.IDPCustomFields)["field1"] = "val2"
|
||||||
assert.NotEqual(t, params.IDPCustomFields, paramsCopy.IDPCustomFields)
|
assert.NotEqual(t, params.IDPCustomFields, paramsCopy.IDPCustomFields)
|
||||||
|
params.Metadata = map[string]string{"key": "value"}
|
||||||
|
paramsCopy = params.getACopy()
|
||||||
|
params.Metadata["key1"] = "value1"
|
||||||
|
require.Equal(t, map[string]string{"key": "value"}, paramsCopy.Metadata)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEventParamsStatusFromError(t *testing.T) {
|
func TestEventParamsStatusFromError(t *testing.T) {
|
||||||
|
|
Loading…
Reference in a new issue