Skip to content

Commit

Permalink
eventmanager: fix params copy
Browse files Browse the repository at this point in the history
Signed-off-by: Nicola Murino <[email protected]>
  • Loading branch information
drakkan committed Aug 12, 2023
1 parent f03fdd1 commit 6395fa0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/common/eventmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,13 @@ func (p *EventParams) getACopy() *EventParams {
}
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 &params
}
Expand Down
4 changes: 4 additions & 0 deletions internal/common/eventmanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2056,6 +2056,10 @@ func TestEventParamsCopy(t *testing.T) {
assert.Equal(t, params.IDPCustomFields, paramsCopy.IDPCustomFields)
(*paramsCopy.IDPCustomFields)["field1"] = "val2"
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) {
Expand Down

0 comments on commit 6395fa0

Please sign in to comment.