@@ -566,3 +566,49 @@ func TestWorker_send_Logging_VerboseDisabled(t *testing.T) {
566
566
567
567
assert .Empty (t , hook .AllEntries ())
568
568
}
569
+ func TestUpdateEntityMetadata (t * testing.T ) {
570
+ t .Parallel ()
571
+ expected := & entity.Fields {
572
+ Name : "WIN_SERVICE:testWindows:newrelic-infra" ,
573
+ Type : "WIN_SERVICE" ,
574
+ IDAttributes : nil ,
575
+ DisplayName : "New Relic Infrastructure Agent" ,
576
+ Metadata : map [string ]interface {}{
577
+ "environment" : "dev" ,
578
+ "backup" : "true" ,
579
+ },
580
+ }
581
+ labels := map [string ]string {
582
+ "environment" : "dev" ,
583
+ "backup" : "true" ,
584
+ }
585
+ entity := & entity.Fields {
586
+ Name : "WIN_SERVICE:testWindows:newrelic-infra" ,
587
+ Type : "WIN_SERVICE" ,
588
+ IDAttributes : nil ,
589
+ DisplayName : "New Relic Infrastructure Agent" ,
590
+ Metadata : map [string ]interface {}{},
591
+ }
592
+ updateEntityMetadata (entity , labels )
593
+ assert .Equal (t , expected , entity )
594
+ }
595
+ func TestUpdateEntityMetadata_NilLabels (t * testing.T ) {
596
+ t .Parallel ()
597
+ expected := & entity.Fields {
598
+ Name : "WIN_SERVICE:testWindows:newrelic-infra" ,
599
+ Type : "WIN_SERVICE" ,
600
+ IDAttributes : nil ,
601
+ DisplayName : "New Relic Infrastructure Agent" ,
602
+ Metadata : map [string ]interface {}{},
603
+ }
604
+ var labels map [string ]string
605
+ entity := & entity.Fields {
606
+ Name : "WIN_SERVICE:testWindows:newrelic-infra" ,
607
+ Type : "WIN_SERVICE" ,
608
+ IDAttributes : nil ,
609
+ DisplayName : "New Relic Infrastructure Agent" ,
610
+ Metadata : map [string ]interface {}{},
611
+ }
612
+ updateEntityMetadata (entity , labels )
613
+ assert .Equal (t , expected , entity )
614
+ }
0 commit comments