@@ -389,6 +389,104 @@ func TestCollectPoliciesReport(t *testing.T) {
389389 }
390390}
391391
392+ func TestCollectIsPlus (t * testing.T ) {
393+ t .Parallel ()
394+
395+ testCases := []struct {
396+ name string
397+ isPlus bool
398+ want bool
399+ }{
400+ {
401+ name : "Plus enabled" ,
402+ isPlus : true ,
403+ want : true ,
404+ },
405+ {
406+ name : "Plus disabled" ,
407+ isPlus : false ,
408+ want : false ,
409+ },
410+ }
411+
412+ for _ , tc := range testCases {
413+ t .Run (tc .name , func (t * testing.T ) {
414+ buf := & bytes.Buffer {}
415+ exp := & telemetry.StdoutExporter {Endpoint : buf }
416+
417+ configurator := newConfiguratorWithIngress (t )
418+
419+ cfg := telemetry.CollectorConfig {
420+ Configurator : configurator ,
421+ K8sClientReader : newTestClientset (node1 , kubeNS ),
422+ Version : telemetryNICData .ProjectVersion ,
423+ IsPlus : tc .isPlus ,
424+ }
425+
426+ c , err := telemetry .NewCollector (cfg , telemetry .WithExporter (exp ))
427+ if err != nil {
428+ t .Fatal (err )
429+ }
430+ c .Collect (context .Background ())
431+
432+ ver := c .IsPlusEnabled ()
433+
434+ if tc .want != ver {
435+ t .Errorf ("want: %t, got: %t" , tc .want , ver )
436+ }
437+ })
438+ }
439+ }
440+
441+ func TestCollectInvalidIsPlus (t * testing.T ) {
442+ t .Parallel ()
443+
444+ testCases := []struct {
445+ name string
446+ isPlus bool
447+ want bool
448+ }{
449+ {
450+ name : "Plus disabled but want enabled" ,
451+ isPlus : false ,
452+ want : true ,
453+ },
454+ {
455+ name : "Plus disabled but want enabled" ,
456+ isPlus : false ,
457+ want : true ,
458+ },
459+ }
460+
461+ for _ , tc := range testCases {
462+ t .Run (tc .name , func (t * testing.T ) {
463+ buf := & bytes.Buffer {}
464+ exp := & telemetry.StdoutExporter {Endpoint : buf }
465+
466+ configurator := newConfiguratorWithIngress (t )
467+
468+ cfg := telemetry.CollectorConfig {
469+ Configurator : configurator ,
470+ K8sClientReader : newTestClientset (node1 , kubeNS ),
471+ Version : telemetryNICData .ProjectVersion ,
472+ IsPlus : tc .isPlus ,
473+ }
474+
475+ c , err := telemetry .NewCollector (cfg , telemetry .WithExporter (exp ))
476+ if err != nil {
477+ t .Fatal (err )
478+ }
479+ c .Collect (context .Background ())
480+
481+ ver := c .IsPlusEnabled ()
482+
483+ if tc .want == ver {
484+ t .Errorf ("want: %t, got: %t" , tc .want , ver )
485+ }
486+ })
487+ }
488+ }
489+
392490func TestIngressCountReportsNoDeployedIngresses (t * testing.T ) {
393491 t .Parallel ()
394492
0 commit comments