diff --git a/pkg/entities/tags_integration_test.go b/pkg/entities/tags_integration_test.go index 7d199f5db..91ba07718 100644 --- a/pkg/entities/tags_integration_test.go +++ b/pkg/entities/tags_integration_test.go @@ -4,9 +4,9 @@ package entities import ( - "testing" - "github.com/stretchr/testify/require" + "regexp" + "testing" "github.com/newrelic/newrelic-client-go/v2/pkg/common" "github.com/newrelic/newrelic-client-go/v2/pkg/testhelpers" @@ -61,6 +61,7 @@ func TestIntegrationTaggingAddTagsToEntityAndGetTags(t *testing.T) { require.NoError(t, err) require.Greater(t, len(actual), 0) + } func TestIntegrationTaggingReplaceTagsOnEntity(t *testing.T) { @@ -83,6 +84,7 @@ func TestIntegrationTaggingReplaceTagsOnEntity(t *testing.T) { require.NoError(t, err) require.NotNil(t, result) require.Equal(t, 0, len(result.Errors)) + } func TestIntegrationDeleteTags(t *testing.T) { @@ -123,3 +125,39 @@ func TestIntegrationDeleteTagValues(t *testing.T) { require.NotNil(t, result) require.Equal(t, 0, len(result.Errors)) } + +func TestIntegrationEntityTagsReservedKeysMutation(t *testing.T) { + t.Parallel() + + var ( + testGUID = common.EntityGUID(testhelpers.IntegrationTestApplicationEntityGUID) + ) + + client := newIntegrationTestClient(t) + + // Test: To add a reserved key(immutable key) + tags := []TaggingTagInput{ + { + Key: "account", + Values: []string{"Random-name"}, + }, + } + result, err := client.TaggingAddTagsToEntity(testGUID, tags) + require.NoError(t, err) + require.NotNil(t, result) + require.Greater(t, len(result.Errors), 0) + message := result.Errors[0].Message + match, er := regexp.MatchString("reserved", message) + require.NoError(t, er) + require.True(t, match) + + // Test: To update a reserved key(immutable key) + result, err = client.TaggingReplaceTagsOnEntity(testGUID, tags) + require.NoError(t, err) + require.NotNil(t, result) + require.Greater(t, len(result.Errors), 0) + message = result.Errors[0].Message + match, er = regexp.MatchString("reserved", message) + require.NoError(t, er) + require.True(t, match) +}