4
4
package entities
5
5
6
6
import (
7
- "testing"
8
-
9
7
"github.com/stretchr/testify/require"
8
+ "regexp"
9
+ "testing"
10
10
11
11
"github.com/newrelic/newrelic-client-go/v2/pkg/common"
12
12
"github.com/newrelic/newrelic-client-go/v2/pkg/testhelpers"
@@ -61,6 +61,7 @@ func TestIntegrationTaggingAddTagsToEntityAndGetTags(t *testing.T) {
61
61
62
62
require .NoError (t , err )
63
63
require .Greater (t , len (actual ), 0 )
64
+
64
65
}
65
66
66
67
func TestIntegrationTaggingReplaceTagsOnEntity (t * testing.T ) {
@@ -83,6 +84,7 @@ func TestIntegrationTaggingReplaceTagsOnEntity(t *testing.T) {
83
84
require .NoError (t , err )
84
85
require .NotNil (t , result )
85
86
require .Equal (t , 0 , len (result .Errors ))
87
+
86
88
}
87
89
88
90
func TestIntegrationDeleteTags (t * testing.T ) {
@@ -123,3 +125,39 @@ func TestIntegrationDeleteTagValues(t *testing.T) {
123
125
require .NotNil (t , result )
124
126
require .Equal (t , 0 , len (result .Errors ))
125
127
}
128
+
129
+ func TestIntegrationEntityTagsReservedKeysMutation (t * testing.T ) {
130
+ t .Parallel ()
131
+
132
+ var (
133
+ testGUID = common .EntityGUID (testhelpers .IntegrationTestApplicationEntityGUID )
134
+ )
135
+
136
+ client := newIntegrationTestClient (t )
137
+
138
+ // Test: To add a reserved key(immutable key)
139
+ tags := []TaggingTagInput {
140
+ {
141
+ Key : "account" ,
142
+ Values : []string {"Random-name" },
143
+ },
144
+ }
145
+ result , err := client .TaggingAddTagsToEntity (testGUID , tags )
146
+ require .NoError (t , err )
147
+ require .NotNil (t , result )
148
+ require .Greater (t , len (result .Errors ), 0 )
149
+ message := result .Errors [0 ].Message
150
+ match , er := regexp .MatchString ("reserved" , message )
151
+ require .NoError (t , er )
152
+ require .True (t , match )
153
+
154
+ // Test: To update a reserved key(immutable key)
155
+ result , err = client .TaggingReplaceTagsOnEntity (testGUID , tags )
156
+ require .NoError (t , err )
157
+ require .NotNil (t , result )
158
+ require .Greater (t , len (result .Errors ), 0 )
159
+ message = result .Errors [0 ].Message
160
+ match , er = regexp .MatchString ("reserved" , message )
161
+ require .NoError (t , er )
162
+ require .True (t , match )
163
+ }
0 commit comments