@@ -240,7 +240,6 @@ func Test_initRetriever(t *testing.T) {
240
240
})
241
241
}
242
242
}
243
-
244
243
func Test_initRetrievers (t * testing.T ) {
245
244
tests := []struct {
246
245
name string
@@ -295,9 +294,6 @@ func Test_initRetrievers(t *testing.T) {
295
294
Kind : "unknown" ,
296
295
},
297
296
},
298
- retriever : & config.RetrieverConf {
299
- Kind : "unknown" ,
300
- },
301
297
},
302
298
{
303
299
name : "only retriever" ,
@@ -349,6 +345,102 @@ func Test_initRetrievers(t *testing.T) {
349
345
}
350
346
}
351
347
348
+ func Test_initExporters (t * testing.T ) {
349
+ tests := []struct {
350
+ name string
351
+ exporters * []config.ExporterConf
352
+ exporter * config.ExporterConf
353
+ wantErr assert.ErrorAssertionFunc
354
+ }{
355
+ {
356
+ name : "both exporter and exporters" ,
357
+ wantErr : assert .NoError ,
358
+ exporter : & config.ExporterConf {
359
+ Kind : "webhook" ,
360
+ EndpointURL : "https://gofeatureflag.org/webhook-example" ,
361
+ Secret : "1234" ,
362
+ },
363
+ exporters : & []config.ExporterConf {
364
+ {
365
+ Kind : "webhook" ,
366
+ EndpointURL : "https://gofeatureflag.org/webhook-example" ,
367
+ Secret : "1234" ,
368
+ },
369
+ },
370
+ },
371
+ {
372
+ name : "exporter only" ,
373
+ wantErr : assert .NoError ,
374
+ exporter : & config.ExporterConf {
375
+ Kind : "webhook" ,
376
+ EndpointURL : "https://gofeatureflag.org/webhook-example" ,
377
+ Secret : "1234" ,
378
+ },
379
+ },
380
+ {
381
+ name : "exporters only" ,
382
+ wantErr : assert .NoError ,
383
+ exporters : & []config.ExporterConf {
384
+ {
385
+ Kind : "webhook" ,
386
+ EndpointURL : "https://gofeatureflag.org/webhook-example" ,
387
+ Secret : "1234" ,
388
+ },
389
+ },
390
+ },
391
+ {
392
+ name : "invalid exporter" ,
393
+ wantErr : assert .Error ,
394
+ exporter : & config.ExporterConf {
395
+ Kind : "invalid" ,
396
+ },
397
+ exporters : & []config.ExporterConf {
398
+ {
399
+ Kind : "webhook" ,
400
+ EndpointURL : "https://gofeatureflag.org/webhook-example" ,
401
+ Secret : "1234" ,
402
+ },
403
+ },
404
+ },
405
+ {
406
+ name : "invalid exporters" ,
407
+ wantErr : assert .Error ,
408
+ exporter : & config.ExporterConf {
409
+
410
+ Kind : "webhook" ,
411
+ EndpointURL : "https://gofeatureflag.org/webhook-example" ,
412
+ Secret : "1234" ,
413
+ },
414
+ exporters : & []config.ExporterConf {
415
+ {
416
+ Kind : "invalid" ,
417
+ },
418
+ },
419
+ },
420
+ }
421
+
422
+ for _ , tt := range tests {
423
+ t .Run (tt .name , func (t * testing.T ) {
424
+ proxyConf := config.Config {
425
+ Exporters : tt .exporters ,
426
+ Exporter : tt .exporter ,
427
+ }
428
+ r , err := initDataExporters (& proxyConf )
429
+ tt .wantErr (t , err )
430
+ if r != nil {
431
+ nbExp := 0
432
+ if tt .exporters != nil {
433
+ nbExp += len (* tt .exporters )
434
+ }
435
+ if tt .exporter != nil {
436
+ nbExp ++
437
+ }
438
+ assert .Len (t , r , nbExp )
439
+ }
440
+ })
441
+ }
442
+ }
443
+
352
444
func Test_initExporter (t * testing.T ) {
353
445
tests := []struct {
354
446
name string
0 commit comments