You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by da...@apache.org on 2018/02/22 16:57:21 UTC

[incubator-trafficcontrol] 12/23: updated to only deleteByID

This is an automated email from the ASF dual-hosted git repository.

dangogh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-trafficcontrol.git

commit c7397f9e6fda996cb777a7a0a899c661b4686559
Author: Dewayne Richardson <de...@apache.org>
AuthorDate: Mon Feb 19 13:31:11 2018 -0700

    updated to only deleteByID
---
 traffic_ops/client/cdn.go                |  6 +++---
 traffic_ops/testing/api/v13/cdns_test.go | 17 ++++++++++++-----
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/traffic_ops/client/cdn.go b/traffic_ops/client/cdn.go
index 7ab3c90..6bf2d93 100644
--- a/traffic_ops/client/cdn.go
+++ b/traffic_ops/client/cdn.go
@@ -117,9 +117,9 @@ func (to *Session) GetCDNByName(name string) ([]tc.CDN, ReqInf, error) {
 	return data.Response, reqInf, nil
 }
 
-// DELETE a CDN by CDN name
-func (to *Session) DeleteCDNByName(name string) (tc.Alerts, ReqInf, error) {
-	route := fmt.Sprintf("%s/name/%s", API_v2_CDNs, name)
+// DELETE a CDN by ID
+func (to *Session) DeleteCDNByID(id int) (tc.Alerts, ReqInf, error) {
+	route := fmt.Sprintf("%s/%d", API_v2_CDNs, id)
 	resp, remoteAddr, err := to.request(http.MethodDelete, route, nil)
 	reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: remoteAddr}
 	if err != nil {
diff --git a/traffic_ops/testing/api/v13/cdns_test.go b/traffic_ops/testing/api/v13/cdns_test.go
index 2e425b1..1a7d9a8 100644
--- a/traffic_ops/testing/api/v13/cdns_test.go
+++ b/traffic_ops/testing/api/v13/cdns_test.go
@@ -84,18 +84,25 @@ func GetTestCDNs(t *testing.T) {
 
 func DeleteTestCDNs(t *testing.T) {
 
-	secondCDN := testData.CDNs[1]
-	resp, _, err := TOSession.DeleteCDNByName(secondCDN.Name)
+	cdn := testData.CDNs[1]
+	// Retrieve the CDN by name so we can get the id for the Update
+	resp, _, err := TOSession.GetCDNByName(cdn.Name)
+	if err != nil {
+		t.Errorf("cannot GET CDN by name: %v - %v\n", cdn.Name, err)
+	}
+	respCDN := resp[0]
+
+	delResp, _, err := TOSession.DeleteCDNByID(respCDN.ID)
 	if err != nil {
-		t.Errorf("cannot DELETE CDN by name: %v - %v\n", err, resp)
+		t.Errorf("cannot DELETE CDN by name: %v - %v\n", err, delResp)
 	}
 
 	// Retrieve the CDN to see if it got deleted
-	cdns, _, err := TOSession.GetCDNByName(secondCDN.Name)
+	cdns, _, err := TOSession.GetCDNByName(cdn.Name)
 	if err != nil {
 		t.Errorf("error deleting CDN name: %s\n", err.Error())
 	}
 	if len(cdns) > 0 {
-		t.Errorf("expected CDN name: %s to be deleted\n", secondCDN.Name)
+		t.Errorf("expected CDN name: %s to be deleted\n", cdn.Name)
 	}
 }

-- 
To stop receiving notification emails like this one, please contact
dangogh@apache.org.