-
Notifications
You must be signed in to change notification settings - Fork 2
[LFXV2-1223] Fix delete object ID corruption #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mauriciozanettisalomao
merged 3 commits into
linuxfoundation:main
from
mauriciozanettisalomao:feat/lfxv2-1223-eventing-handlers-indexer-access
Mar 16, 2026
+131
−4
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
45f134b
Enhance transaction data decoding with detailed logging and add compr…
mauriciozanettisalomao 19b67e1
Add GroupsIO mailing list enrichment functions and corresponding tests
mauriciozanettisalomao bc528cf
Refactor GroupsIO mailing list enricher by removing unused extraction…
mauriciozanettisalomao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
134 changes: 134 additions & 0 deletions
134
internal/enrichers/groupsio_mailing_list_enricher_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| // Copyright The Linux Foundation and each contributor to LFX. | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| package enrichers | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/linuxfoundation/lfx-v2-indexer-service/internal/domain/contracts" | ||
| "github.com/linuxfoundation/lfx-v2-indexer-service/pkg/constants" | ||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestGroupsIOMailingListEnricher_ObjectType(t *testing.T) { | ||
| enricher := NewGroupsIOMailingListEnricher() | ||
| assert.Equal(t, constants.ObjectTypeGroupsIOMailingList, enricher.ObjectType()) | ||
| } | ||
|
|
||
| func TestGroupsIOMailingListEnricher_EnrichData(t *testing.T) { | ||
| enricher := NewGroupsIOMailingListEnricher() | ||
|
|
||
| tests := []struct { | ||
| name string | ||
| parsedData map[string]any | ||
| expectedBody *contracts.TransactionBody | ||
| expectedError string | ||
| }{ | ||
| { | ||
| name: "group_name used as sort name and alias", | ||
| parsedData: map[string]any{ | ||
| "uid": "ml-123", | ||
| "group_name": "My Mailing List", | ||
| }, | ||
| expectedBody: &contracts.TransactionBody{ | ||
| ObjectID: "ml-123", | ||
| SortName: "My Mailing List", | ||
| NameAndAliases: []string{"My Mailing List"}, | ||
| }, | ||
| }, | ||
| { | ||
| name: "group_name takes priority over name field", | ||
| parsedData: map[string]any{ | ||
| "uid": "ml-456", | ||
| "group_name": "Group Name", | ||
| "name": "Other Name", | ||
| }, | ||
| expectedBody: &contracts.TransactionBody{ | ||
| ObjectID: "ml-456", | ||
| SortName: "Group Name", | ||
| }, | ||
| }, | ||
| { | ||
| name: "both group_name and name appear in aliases", | ||
| parsedData: map[string]any{ | ||
| "uid": "ml-789", | ||
| "group_name": "Group Name", | ||
| "name": "Other Name", | ||
| }, | ||
| expectedBody: &contracts.TransactionBody{ | ||
| ObjectID: "ml-789", | ||
| SortName: "Group Name", | ||
| NameAndAliases: []string{"Group Name", "Other Name"}, | ||
| }, | ||
| }, | ||
| { | ||
| name: "fallback to name when group_name absent", | ||
| parsedData: map[string]any{ | ||
| "uid": "ml-fallback", | ||
| "name": "Fallback Name", | ||
| }, | ||
| expectedBody: &contracts.TransactionBody{ | ||
| ObjectID: "ml-fallback", | ||
| SortName: "Fallback Name", | ||
| NameAndAliases: []string{"Fallback Name"}, | ||
| }, | ||
| }, | ||
| { | ||
| name: "group_name whitespace trimmed", | ||
| parsedData: map[string]any{ | ||
| "uid": "ml-trim", | ||
| "group_name": " Trimmed ", | ||
| }, | ||
| expectedBody: &contracts.TransactionBody{ | ||
| ObjectID: "ml-trim", | ||
| SortName: "Trimmed", | ||
| NameAndAliases: []string{"Trimmed"}, | ||
| }, | ||
| }, | ||
| { | ||
| name: "empty group_name falls back to name", | ||
| parsedData: map[string]any{ | ||
| "uid": "ml-empty", | ||
| "group_name": "", | ||
| "name": "Fallback", | ||
| }, | ||
| expectedBody: &contracts.TransactionBody{ | ||
| ObjectID: "ml-empty", | ||
| SortName: "Fallback", | ||
| }, | ||
| }, | ||
| { | ||
| name: "error: missing uid and id", | ||
| parsedData: map[string]any{ | ||
| "group_name": "Some List", | ||
| }, | ||
| expectedError: constants.ErrMappingUID, | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| body := &contracts.TransactionBody{} | ||
| transaction := &contracts.LFXTransaction{ | ||
| ParsedData: tt.parsedData, | ||
| } | ||
|
|
||
| err := enricher.EnrichData(body, transaction) | ||
|
|
||
| if tt.expectedError != "" { | ||
| require.Error(t, err) | ||
| assert.Contains(t, err.Error(), tt.expectedError) | ||
| return | ||
| } | ||
|
|
||
| require.NoError(t, err) | ||
| assert.Equal(t, tt.expectedBody.ObjectID, body.ObjectID) | ||
| assert.Equal(t, tt.expectedBody.SortName, body.SortName) | ||
| if tt.expectedBody.NameAndAliases != nil { | ||
| assert.Equal(t, tt.expectedBody.NameAndAliases, body.NameAndAliases) | ||
| } | ||
| }) | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.