@@ -70,8 +70,11 @@ func postNewGroup() string {
70
70
return c
71
71
}
72
72
73
- func postNewTag (groupID string ) string {
73
+ func postNewTag (groupID string , tag string ) string {
74
74
postData := url.Values {}
75
+ if tag != "" {
76
+ postData .Set ("tag" , tag )
77
+ }
75
78
postData .Set ("CSRFToken" , CsrfToken )
76
79
77
80
res , _ := client .PostForm (RootOrgchartURL + `api/group/` + groupID + `/tag` , postData )
@@ -97,9 +100,12 @@ func importGroup(groupID string) string {
97
100
return c
98
101
}
99
102
100
- func removeNexusGroup (postUrl string ) error {
103
+ func removeFromNexus (postUrl string , tag string ) error {
101
104
102
105
data := url.Values {}
106
+ if tag != "" {
107
+ data .Set ("tag" , tag )
108
+ }
103
109
data .Set ("CSRFToken" , CsrfToken )
104
110
105
111
req , err := http .NewRequest ("DELETE" , postUrl , strings .NewReader (data .Encode ()))
@@ -144,7 +150,7 @@ func TestGroup_syncServices(t *testing.T) {
144
150
groupID := postNewGroup ()
145
151
id , _ := strconv .Atoi (groupID )
146
152
var passed = false
147
- postNewTag (groupID )
153
+ postNewTag (groupID , "" )
148
154
importGroup (groupID )
149
155
150
156
// check that the group exists in both nexus and portal
@@ -176,7 +182,7 @@ func TestGroup_syncServices(t *testing.T) {
176
182
}
177
183
178
184
// remove this group from the nexus
179
- err := removeNexusGroup (fmt .Sprintf ("%sapi/group/%s" , RootOrgchartURL , groupID ))
185
+ err := removeFromNexus (fmt .Sprintf ("%sapi/group/%s" , RootOrgchartURL , groupID ), "" )
180
186
181
187
if err != nil {
182
188
t .Error (err )
@@ -219,3 +225,48 @@ func TestGroup_syncServices(t *testing.T) {
219
225
t .Errorf ("Portal group was not removed and should have been" )
220
226
}
221
227
}
228
+
229
+ func TestGroup_removeTag (t * testing.T ) {
230
+ // add a tag to a group
231
+ id := "34"
232
+ id_int , _ := strconv .Atoi (id )
233
+ passed := false
234
+ tag_name := "Academy_Demo1"
235
+ postNewTag (id , tag_name )
236
+
237
+ // check to make sure tag was added
238
+ o_groups := getNexusGroup (RootOrgchartURL + `api/group/list` )
239
+
240
+ for _ , o_group := range o_groups {
241
+ if id_int == o_group .GroupID {
242
+ passed = true
243
+ break
244
+ }
245
+ }
246
+
247
+ if passed == false {
248
+ t .Errorf ("The tag was not found in this group" )
249
+ }
250
+
251
+ // remove the tag
252
+ err := removeFromNexus (fmt .Sprintf ("%sapi/group/%s/tag?" , RootOrgchartURL , id ), tag_name )
253
+
254
+ if err != nil {
255
+ t .Error (err )
256
+ }
257
+
258
+ // check to make sure tag was removed
259
+ passed = false
260
+ o_groups = getNexusGroup (RootOrgchartURL + `api/group/list` )
261
+
262
+ for _ , o_group := range o_groups {
263
+ if (id_int == o_group .GroupID ) && (tag_name == o_group .GroupTitle ) {
264
+ passed = true
265
+ break
266
+ }
267
+ }
268
+
269
+ if passed == true {
270
+ t .Errorf ("The tag was not removed from this group" )
271
+ }
272
+ }
0 commit comments