@@ -44,10 +44,17 @@ func TestValidate(t *testing.T) {
44
44
},
45
45
err : ErrUnsetAPIKey .Error (),
46
46
},
47
+ {
48
+ name : "invalid format api::key" ,
49
+ cfg : & Config {
50
+ API : APIConfig {Key : "'aaaaaaa" },
51
+ },
52
+ err : ErrAPIKeyFormat .Error (),
53
+ },
47
54
{
48
55
name : "invalid hostname" ,
49
56
cfg : & Config {
50
- API : APIConfig {Key : "notnull " },
57
+ API : APIConfig {Key : "aaaaaaa " },
51
58
TagsConfig : TagsConfig {Hostname : "invalid_host" },
52
59
HostMetadata : HostMetadataConfig {Enabled : true , ReporterPeriod : 10 * time .Minute },
53
60
},
@@ -56,7 +63,7 @@ func TestValidate(t *testing.T) {
56
63
{
57
64
name : "no metadata" ,
58
65
cfg : & Config {
59
- API : APIConfig {Key : "notnull " },
66
+ API : APIConfig {Key : "aaaaaaa " },
60
67
OnlyMetadata : true ,
61
68
HostMetadata : HostMetadataConfig {Enabled : true , ReporterPeriod : 10 * time .Minute },
62
69
},
@@ -65,15 +72,15 @@ func TestValidate(t *testing.T) {
65
72
{
66
73
name : "span name remapping valid" ,
67
74
cfg : & Config {
68
- API : APIConfig {Key : "notnull " },
75
+ API : APIConfig {Key : "aaaaaaa " },
69
76
Traces : TracesExporterConfig {TracesConfig : TracesConfig {SpanNameRemappings : map [string ]string {"old.opentelemetryspan.name" : "updated.name" }}},
70
77
HostMetadata : HostMetadataConfig {Enabled : true , ReporterPeriod : 10 * time .Minute },
71
78
},
72
79
},
73
80
{
74
81
name : "span name remapping empty val" ,
75
82
cfg : & Config {
76
- API : APIConfig {Key : "notnull " },
83
+ API : APIConfig {Key : "aaaaaaa " },
77
84
Traces : TracesExporterConfig {TracesConfig : TracesConfig {SpanNameRemappings : map [string ]string {"oldname" : "" }}},
78
85
HostMetadata : HostMetadataConfig {Enabled : true , ReporterPeriod : 10 * time .Minute },
79
86
},
@@ -82,7 +89,7 @@ func TestValidate(t *testing.T) {
82
89
{
83
90
name : "span name remapping empty key" ,
84
91
cfg : & Config {
85
- API : APIConfig {Key : "notnull " },
92
+ API : APIConfig {Key : "aaaaaaa " },
86
93
Traces : TracesExporterConfig {TracesConfig : TracesConfig {SpanNameRemappings : map [string ]string {"" : "newname" }}},
87
94
HostMetadata : HostMetadataConfig {Enabled : true , ReporterPeriod : 10 * time .Minute },
88
95
},
@@ -91,15 +98,15 @@ func TestValidate(t *testing.T) {
91
98
{
92
99
name : "ignore resources valid" ,
93
100
cfg : & Config {
94
- API : APIConfig {Key : "notnull " },
101
+ API : APIConfig {Key : "aaaaaaa " },
95
102
Traces : TracesExporterConfig {TracesConfig : TracesConfig {IgnoreResources : []string {"[123]" }}},
96
103
HostMetadata : HostMetadataConfig {Enabled : true , ReporterPeriod : 10 * time .Minute },
97
104
},
98
105
},
99
106
{
100
107
name : "ignore resources missing bracket" ,
101
108
cfg : & Config {
102
- API : APIConfig {Key : "notnull " },
109
+ API : APIConfig {Key : "aaaaaaa " },
103
110
Traces : TracesExporterConfig {TracesConfig : TracesConfig {IgnoreResources : []string {"[123" }}},
104
111
HostMetadata : HostMetadataConfig {Enabled : true , ReporterPeriod : 10 * time .Minute },
105
112
},
@@ -108,7 +115,7 @@ func TestValidate(t *testing.T) {
108
115
{
109
116
name : "invalid histogram settings" ,
110
117
cfg : & Config {
111
- API : APIConfig {Key : "notnull " },
118
+ API : APIConfig {Key : "aaaaaaa " },
112
119
Metrics : MetricsConfig {
113
120
HistConfig : HistogramConfig {
114
121
Mode : HistogramModeNoBuckets ,
@@ -122,7 +129,7 @@ func TestValidate(t *testing.T) {
122
129
{
123
130
name : "TLS settings are valid" ,
124
131
cfg : & Config {
125
- API : APIConfig {Key : "notnull " },
132
+ API : APIConfig {Key : "aaaaaaa " },
126
133
ClientConfig : confighttp.ClientConfig {
127
134
TLSSetting : configtls.ClientConfig {
128
135
InsecureSkipVerify : true ,
@@ -134,15 +141,15 @@ func TestValidate(t *testing.T) {
134
141
{
135
142
name : "With trace_buffer" ,
136
143
cfg : & Config {
137
- API : APIConfig {Key : "notnull " },
144
+ API : APIConfig {Key : "aaaaaaa " },
138
145
Traces : TracesExporterConfig {TraceBuffer : 10 },
139
146
HostMetadata : HostMetadataConfig {Enabled : true , ReporterPeriod : 10 * time .Minute },
140
147
},
141
148
},
142
149
{
143
150
name : "With peer_tags" ,
144
151
cfg : & Config {
145
- API : APIConfig {Key : "notnull " },
152
+ API : APIConfig {Key : "aaaaaaa " },
146
153
Traces : TracesExporterConfig {
147
154
TracesConfig : TracesConfig {
148
155
PeerTags : []string {"tag1" , "tag2" },
@@ -154,7 +161,7 @@ func TestValidate(t *testing.T) {
154
161
{
155
162
name : "With confighttp client configs" ,
156
163
cfg : & Config {
157
- API : APIConfig {Key : "notnull " },
164
+ API : APIConfig {Key : "aaaaaaa " },
158
165
ClientConfig : confighttp.ClientConfig {
159
166
ReadBufferSize : 100 ,
160
167
WriteBufferSize : 200 ,
@@ -173,7 +180,7 @@ func TestValidate(t *testing.T) {
173
180
{
174
181
name : "unsupported confighttp client configs" ,
175
182
cfg : & Config {
176
- API : APIConfig {Key : "notnull " },
183
+ API : APIConfig {Key : "aaaaaaa " },
177
184
ClientConfig : confighttp.ClientConfig {
178
185
Endpoint : "endpoint" ,
179
186
Compression : "gzip" ,
@@ -189,7 +196,7 @@ func TestValidate(t *testing.T) {
189
196
{
190
197
name : "Invalid reporter_period" ,
191
198
cfg : & Config {
192
- API : APIConfig {Key : "notnull " },
199
+ API : APIConfig {Key : "abcdef0 " },
193
200
HostMetadata : HostMetadataConfig {Enabled : true , ReporterPeriod : 4 * time .Minute },
194
201
},
195
202
err : "reporter_period must be 5 minutes or higher" ,
@@ -199,7 +206,7 @@ func TestValidate(t *testing.T) {
199
206
t .Run (testInstance .name , func (t * testing.T ) {
200
207
err := testInstance .cfg .Validate ()
201
208
if testInstance .err != "" {
202
- assert .EqualError (t , err , testInstance .err )
209
+ assert .ErrorContains (t , err , testInstance .err )
203
210
} else {
204
211
assert .NoError (t , err )
205
212
}
@@ -649,7 +656,7 @@ func TestLoadConfig(t *testing.T) {
649
656
BackOffConfig : configretry .NewDefaultBackOffConfig (),
650
657
QueueSettings : exporterhelper .NewDefaultQueueConfig (),
651
658
API : APIConfig {
652
- Key : "key " ,
659
+ Key : "abc " ,
653
660
Site : "datadoghq.com" ,
654
661
FailOnInvalidKey : false ,
655
662
},
0 commit comments