Skip to content

Commit

Permalink
[processor/geoipprocessor] Refactor record_custom_address test case
Browse files Browse the repository at this point in the history
  • Loading branch information
bencehornak committed Jan 7, 2025
1 parent e6ca723 commit 0a5d848
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions processor/geoipprocessor/geoip_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@ var baseProviderMock = providerMock{
}

var testCases = []struct {
name string
goldenDir string
context ContextID
name string
goldenDir string
context ContextID
attributes []attribute.Key
}{
{
name: "default source.address attribute, not found",
Expand Down Expand Up @@ -121,9 +122,10 @@ var testCases = []struct {
context: record,
},
{
name: "custom address located in the record attributes",
goldenDir: "record_custom_address",
context: record,
name: "custom address located in the record attributes",
goldenDir: "record_custom_address",
context: record,
attributes: []attribute.Key{"source.address", "client.address", "custom.address"},
},
}

Expand Down Expand Up @@ -221,7 +223,11 @@ func TestProcessor(t *testing.T) {

for _, tt := range testCases {
t.Run(tt.name, func(t *testing.T) {
cfg := &Config{Context: tt.context, Providers: map[string]provider.Config{providerKey: &providerConfigMock{}}, Attributes: []attribute.Key{"source.address", "client.address", "custom.address"}}
var attributes []attribute.Key = defaultAttributes
if tt.attributes != nil {
attributes = tt.attributes
}
cfg := &Config{Context: tt.context, Providers: map[string]provider.Config{providerKey: &providerConfigMock{}}, Attributes: attributes}
compareAllSignals(cfg, tt.goldenDir)(t)
})
}
Expand Down

0 comments on commit 0a5d848

Please sign in to comment.