9
9
"time"
10
10
11
11
"github.com/stretchr/testify/require"
12
+ "go.mongodb.org/atlas/mongodbatlas"
12
13
"go.opentelemetry.io/collector/component"
13
14
"go.opentelemetry.io/collector/config/configtls"
14
15
"go.opentelemetry.io/collector/confmap/confmaptest"
@@ -28,12 +29,14 @@ func TestValidate(t *testing.T) {
28
29
{
29
30
name : "Empty config" ,
30
31
input : Config {
32
+ BaseURL : mongodbatlas .CloudURL ,
31
33
ControllerConfig : scraperhelper .NewDefaultControllerConfig (),
32
34
},
33
35
},
34
36
{
35
37
name : "Valid alerts config" ,
36
38
input : Config {
39
+ BaseURL : mongodbatlas .CloudURL ,
37
40
Alerts : AlertConfig {
38
41
Enabled : true ,
39
42
Endpoint : "0.0.0.0:7706" ,
@@ -46,6 +49,7 @@ func TestValidate(t *testing.T) {
46
49
{
47
50
name : "Alerts missing endpoint" ,
48
51
input : Config {
52
+ BaseURL : mongodbatlas .CloudURL ,
49
53
Alerts : AlertConfig {
50
54
Enabled : true ,
51
55
Secret : "some_secret" ,
@@ -58,6 +62,7 @@ func TestValidate(t *testing.T) {
58
62
{
59
63
name : "Alerts missing secret" ,
60
64
input : Config {
65
+ BaseURL : mongodbatlas .CloudURL ,
61
66
Alerts : AlertConfig {
62
67
Enabled : true ,
63
68
Endpoint : "0.0.0.0:7706" ,
@@ -70,6 +75,7 @@ func TestValidate(t *testing.T) {
70
75
{
71
76
name : "Invalid endpoint" ,
72
77
input : Config {
78
+ BaseURL : mongodbatlas .CloudURL ,
73
79
Alerts : AlertConfig {
74
80
Enabled : true ,
75
81
Endpoint : "7706" ,
@@ -83,6 +89,7 @@ func TestValidate(t *testing.T) {
83
89
{
84
90
name : "TLS config missing key" ,
85
91
input : Config {
92
+ BaseURL : mongodbatlas .CloudURL ,
86
93
Alerts : AlertConfig {
87
94
Enabled : true ,
88
95
Endpoint : "0.0.0.0:7706" ,
@@ -101,6 +108,7 @@ func TestValidate(t *testing.T) {
101
108
{
102
109
name : "TLS config missing cert" ,
103
110
input : Config {
111
+ BaseURL : mongodbatlas .CloudURL ,
104
112
Alerts : AlertConfig {
105
113
Enabled : true ,
106
114
Endpoint : "0.0.0.0:7706" ,
@@ -119,6 +127,7 @@ func TestValidate(t *testing.T) {
119
127
{
120
128
name : "Valid Metrics Config" ,
121
129
input : Config {
130
+ BaseURL : mongodbatlas .CloudURL ,
122
131
Projects : []* ProjectConfig {
123
132
{
124
133
Name : "Project1" ,
@@ -130,6 +139,7 @@ func TestValidate(t *testing.T) {
130
139
{
131
140
name : "Valid Metrics Config with multiple projects with an inclusion or exclusion" ,
132
141
input : Config {
142
+ BaseURL : mongodbatlas .CloudURL ,
133
143
Projects : []* ProjectConfig {
134
144
{
135
145
Name : "Project1" ,
@@ -146,6 +156,7 @@ func TestValidate(t *testing.T) {
146
156
{
147
157
name : "invalid Metrics Config" ,
148
158
input : Config {
159
+ BaseURL : mongodbatlas .CloudURL ,
149
160
Projects : []* ProjectConfig {
150
161
{
151
162
Name : "Project1" ,
@@ -160,6 +171,7 @@ func TestValidate(t *testing.T) {
160
171
{
161
172
name : "Valid Logs Config" ,
162
173
input : Config {
174
+ BaseURL : mongodbatlas .CloudURL ,
163
175
Logs : LogConfig {
164
176
Enabled : true ,
165
177
Projects : []* LogsProjectConfig {
@@ -177,6 +189,7 @@ func TestValidate(t *testing.T) {
177
189
{
178
190
name : "Invalid Logs Config" ,
179
191
input : Config {
192
+ BaseURL : mongodbatlas .CloudURL ,
180
193
Logs : LogConfig {
181
194
Enabled : true ,
182
195
},
@@ -187,6 +200,7 @@ func TestValidate(t *testing.T) {
187
200
{
188
201
name : "Invalid ProjectConfig" ,
189
202
input : Config {
203
+ BaseURL : mongodbatlas .CloudURL ,
190
204
Logs : LogConfig {
191
205
Enabled : true ,
192
206
Projects : []* LogsProjectConfig {
@@ -207,6 +221,7 @@ func TestValidate(t *testing.T) {
207
221
{
208
222
name : "Invalid Alerts Retrieval ProjectConfig" ,
209
223
input : Config {
224
+ BaseURL : mongodbatlas .CloudURL ,
210
225
Alerts : AlertConfig {
211
226
Enabled : true ,
212
227
Mode : alertModePoll ,
@@ -226,6 +241,7 @@ func TestValidate(t *testing.T) {
226
241
{
227
242
name : "Invalid Alerts Poll No Projects" ,
228
243
input : Config {
244
+ BaseURL : mongodbatlas .CloudURL ,
229
245
Alerts : AlertConfig {
230
246
Enabled : true ,
231
247
Mode : alertModePoll ,
@@ -239,6 +255,7 @@ func TestValidate(t *testing.T) {
239
255
{
240
256
name : "Valid Alerts Config" ,
241
257
input : Config {
258
+ BaseURL : mongodbatlas .CloudURL ,
242
259
Alerts : AlertConfig {
243
260
Enabled : true ,
244
261
Mode : alertModePoll ,
@@ -255,6 +272,7 @@ func TestValidate(t *testing.T) {
255
272
{
256
273
name : "Invalid Alerts Mode" ,
257
274
input : Config {
275
+ BaseURL : mongodbatlas .CloudURL ,
258
276
Alerts : AlertConfig {
259
277
Enabled : true ,
260
278
Mode : "invalid type" ,
@@ -267,6 +285,7 @@ func TestValidate(t *testing.T) {
267
285
{
268
286
name : "Invalid Page Size" ,
269
287
input : Config {
288
+ BaseURL : mongodbatlas .CloudURL ,
270
289
Alerts : AlertConfig {
271
290
Enabled : true ,
272
291
Mode : alertModePoll ,
@@ -284,6 +303,7 @@ func TestValidate(t *testing.T) {
284
303
{
285
304
name : "Invalid events config - no projects" ,
286
305
input : Config {
306
+ BaseURL : mongodbatlas .CloudURL ,
287
307
Events : & EventsConfig {
288
308
Projects : []* ProjectConfig {},
289
309
},
@@ -294,6 +314,7 @@ func TestValidate(t *testing.T) {
294
314
{
295
315
name : "Valid Access Logs Config" ,
296
316
input : Config {
317
+ BaseURL : mongodbatlas .CloudURL ,
297
318
Logs : LogConfig {
298
319
Projects : []* LogsProjectConfig {
299
320
{
@@ -314,6 +335,7 @@ func TestValidate(t *testing.T) {
314
335
{
315
336
name : "Invalid Access Logs Config - bad project config" ,
316
337
input : Config {
338
+ BaseURL : mongodbatlas .CloudURL ,
317
339
Logs : LogConfig {
318
340
Enabled : true ,
319
341
Projects : []* LogsProjectConfig {
0 commit comments