forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 1
/
config_test.go
84 lines (79 loc) · 1.81 KB
/
config_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package datadogconnector
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestValidate(t *testing.T) {
tests := []struct {
name string
cfg *Config
err string
}{
{
name: "span name remapping valid",
cfg: &Config{
Traces: TracesConfig{
SpanNameRemappings: map[string]string{"old.opentelemetryspan.name": "updated.name"},
},
},
},
{
name: "span name remapping empty val",
cfg: &Config{Traces: TracesConfig{
SpanNameRemappings: map[string]string{"oldname": ""},
}},
err: "\"\" is not valid value for span name remapping",
},
{
name: "span name remapping empty key",
cfg: &Config{Traces: TracesConfig{
SpanNameRemappings: map[string]string{"": "newname"},
}},
err: "\"\" is not valid key for span name remapping",
},
{
name: "ignore resources valid",
cfg: &Config{Traces: TracesConfig{
IgnoreResources: []string{"[123]"},
}},
},
{
name: "ignore resources missing bracket",
cfg: &Config{Traces: TracesConfig{
IgnoreResources: []string{"[123"},
}},
err: "\"[123\" is not valid resource filter regular expression",
},
{
name: "With trace_buffer",
cfg: &Config{Traces: TracesConfig{
TraceBuffer: 10,
}},
},
{
name: "neg trace_buffer",
cfg: &Config{Traces: TracesConfig{
TraceBuffer: -10,
}},
err: "Trace buffer must be non-negative",
},
{
name: "With peer_tags",
cfg: &Config{
Traces: TracesConfig{PeerTags: []string{"tag1", "tag2"}},
},
},
}
for _, testInstance := range tests {
t.Run(testInstance.name, func(t *testing.T) {
err := testInstance.cfg.Validate()
if testInstance.err != "" {
assert.EqualError(t, err, testInstance.err)
} else {
assert.NoError(t, err)
}
})
}
}