Skip to content

Commit 0a5d848

Browse files
committed
[processor/geoipprocessor] Refactor record_custom_address test case
1 parent e6ca723 commit 0a5d848

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

processor/geoipprocessor/geoip_processor_test.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,10 @@ var baseProviderMock = providerMock{
8181
}
8282

8383
var testCases = []struct {
84-
name string
85-
goldenDir string
86-
context ContextID
84+
name string
85+
goldenDir string
86+
context ContextID
87+
attributes []attribute.Key
8788
}{
8889
{
8990
name: "default source.address attribute, not found",
@@ -121,9 +122,10 @@ var testCases = []struct {
121122
context: record,
122123
},
123124
{
124-
name: "custom address located in the record attributes",
125-
goldenDir: "record_custom_address",
126-
context: record,
125+
name: "custom address located in the record attributes",
126+
goldenDir: "record_custom_address",
127+
context: record,
128+
attributes: []attribute.Key{"source.address", "client.address", "custom.address"},
127129
},
128130
}
129131

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

222224
for _, tt := range testCases {
223225
t.Run(tt.name, func(t *testing.T) {
224-
cfg := &Config{Context: tt.context, Providers: map[string]provider.Config{providerKey: &providerConfigMock{}}, Attributes: []attribute.Key{"source.address", "client.address", "custom.address"}}
226+
var attributes []attribute.Key = defaultAttributes
227+
if tt.attributes != nil {
228+
attributes = tt.attributes
229+
}
230+
cfg := &Config{Context: tt.context, Providers: map[string]provider.Config{providerKey: &providerConfigMock{}}, Attributes: attributes}
225231
compareAllSignals(cfg, tt.goldenDir)(t)
226232
})
227233
}

0 commit comments

Comments
 (0)