Skip to content

Commit

Permalink
add test case with labels as nil
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishuraina committed Jan 13, 2025
1 parent c8742f8 commit 98cd97d
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pkg/entity/register/worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,3 +592,23 @@ func TestUpdateEntityMetadata(t *testing.T) {
updateEntityMetadata(entity, labels)
assert.Equal(t, expected, entity)
}
func TestUpdateEntityMetadata_NilLabels(t *testing.T) {
t.Parallel()
expected := &entity.Fields{
Name: "WIN_SERVICE:testWindows:newrelic-infra",
Type: "WIN_SERVICE",
IDAttributes: nil,
DisplayName: "New Relic Infrastructure Agent",
Metadata: map[string]interface{}{},
}
var labels map[string]string = nil

Check failure on line 604 in pkg/entity/register/worker_test.go

View workflow job for this annotation

GitHub Actions / linter-linux / Run Linter

var-declaration: should drop = nil from declaration of var labels; it is the zero value (revive)

Check failure on line 604 in pkg/entity/register/worker_test.go

View workflow job for this annotation

GitHub Actions / linter-macos / Lint tests

var-declaration: should drop = nil from declaration of var labels; it is the zero value (revive)

Check failure on line 604 in pkg/entity/register/worker_test.go

View workflow job for this annotation

GitHub Actions / linter-windows / Lint tests

var-declaration: should drop = nil from declaration of var labels; it is the zero value (revive)
entity := &entity.Fields{
Name: "WIN_SERVICE:testWindows:newrelic-infra",
Type: "WIN_SERVICE",
IDAttributes: nil,
DisplayName: "New Relic Infrastructure Agent",
Metadata: map[string]interface{}{},
}
updateEntityMetadata(entity, labels)
assert.Equal(t, expected, entity)
}

0 comments on commit 98cd97d

Please sign in to comment.