Skip to content

Commit 3a7ddce

Browse files
committed
Leaf 4682 - test to delete tag nexus side
1 parent 51fda02 commit 3a7ddce

File tree

1 file changed

+55
-4
lines changed

1 file changed

+55
-4
lines changed

API-tests/group_test.go

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,11 @@ func postNewGroup() string {
7070
return c
7171
}
7272

73-
func postNewTag(groupID string) string {
73+
func postNewTag(groupID string, tag string) string {
7474
postData := url.Values{}
75+
if tag != "" {
76+
postData.Set("tag", tag)
77+
}
7578
postData.Set("CSRFToken", CsrfToken)
7679

7780
res, _ := client.PostForm(RootOrgchartURL+`api/group/`+groupID+`/tag`, postData)
@@ -97,9 +100,12 @@ func importGroup(groupID string) string {
97100
return c
98101
}
99102

100-
func removeNexusGroup(postUrl string) error {
103+
func removeFromNexus(postUrl string, tag string) error {
101104

102105
data := url.Values{}
106+
if tag != "" {
107+
data.Set("tag", tag)
108+
}
103109
data.Set("CSRFToken", CsrfToken)
104110

105111
req, err := http.NewRequest("DELETE", postUrl, strings.NewReader(data.Encode()))
@@ -144,7 +150,7 @@ func TestGroup_syncServices(t *testing.T) {
144150
groupID := postNewGroup()
145151
id, _ := strconv.Atoi(groupID)
146152
var passed = false
147-
postNewTag(groupID)
153+
postNewTag(groupID, "")
148154
importGroup(groupID)
149155

150156
// check that the group exists in both nexus and portal
@@ -176,7 +182,7 @@ func TestGroup_syncServices(t *testing.T) {
176182
}
177183

178184
// 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), "")
180186

181187
if err != nil {
182188
t.Error(err)
@@ -219,3 +225,48 @@ func TestGroup_syncServices(t *testing.T) {
219225
t.Errorf("Portal group was not removed and should have been")
220226
}
221227
}
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

Comments
 (0)