mitchell852 closed pull request #2118: cleaned up the teardown functions so 
each test case works as a unit
URL: https://github.com/apache/incubator-trafficcontrol/pull/2118
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/traffic_ops/client/v13/deliveryservice_request_comments.go 
b/traffic_ops/client/v13/deliveryservice_request_comments.go
index 02e0763c9..f8389b6b4 100644
--- a/traffic_ops/client/v13/deliveryservice_request_comments.go
+++ b/traffic_ops/client/v13/deliveryservice_request_comments.go
@@ -21,7 +21,6 @@ import (
        "net/http"
 
        "github.com/apache/incubator-trafficcontrol/lib/go-tc"
-       "github.com/apache/incubator-trafficcontrol/lib/go-log"
 
        "fmt"
 )
@@ -40,7 +39,6 @@ func (to *Session) 
CreateDeliveryServiceRequestComment(comment tc.DeliveryServic
                return tc.Alerts{}, reqInf, err
        }
        resp, remoteAddr, err := to.request(http.MethodPost, 
API_v13_DeliveryServiceRequestComments, reqBody)
-       log.Infof("%s", reqBody)
        if err != nil {
                return tc.Alerts{}, reqInf, err
        }
@@ -115,4 +113,3 @@ func (to *Session) 
DeleteDeliveryServiceRequestCommentByID(id int) (tc.Alerts, R
        err = json.NewDecoder(resp.Body).Decode(&alerts)
        return alerts, reqInf, nil
 }
-
diff --git 
a/traffic_ops/testing/api/v13/deliveryservice_request_comments_test.go 
b/traffic_ops/testing/api/v13/deliveryservice_request_comments_test.go
index 40fda203e..092b13558 100644
--- a/traffic_ops/testing/api/v13/deliveryservice_request_comments_test.go
+++ b/traffic_ops/testing/api/v13/deliveryservice_request_comments_test.go
@@ -18,7 +18,6 @@ package v13
 import (
        "testing"
 
-       "github.com/apache/incubator-trafficcontrol/lib/go-log"
        "github.com/apache/incubator-trafficcontrol/lib/go-tc"
 )
 
@@ -47,9 +46,8 @@ func CreateTestDeliveryServiceRequestComments(t *testing.T) {
        for _, comment := range testData.DeliveryServiceRequestComments {
                comment.DeliveryServiceRequestID = respDSR.ID
                resp, _, err := 
TOSession.CreateDeliveryServiceRequestComment(comment)
-               log.Debugln("Response: ", resp)
                if err != nil {
-                       t.Errorf("could not CREATE delivery service request 
comment: %v\n", err)
+                       t.Errorf("could not CREATE delivery service request 
comment: %v - %v\n", err, resp)
                }
        }
 
diff --git a/traffic_ops/testing/api/v13/divisions_test.go 
b/traffic_ops/testing/api/v13/divisions_test.go
index 954fe7f30..b2c524ddb 100644
--- a/traffic_ops/testing/api/v13/divisions_test.go
+++ b/traffic_ops/testing/api/v13/divisions_test.go
@@ -68,6 +68,13 @@ func UpdateTestDivisions(t *testing.T) {
                t.Errorf("results do not match actual: %s, expected: %s\n", 
respDivision.Name, expectedDivision)
        }
 
+       // Set the name back to the fixture value so we can delete it after
+       remoteDivision.Name = firstDivision.Name
+       alert, _, err = TOSession.UpdateDivisionByID(remoteDivision.ID, 
remoteDivision)
+       if err != nil {
+               t.Errorf("cannot UPDATE Division by id: %v - %v\n", err, alert)
+       }
+
 }
 
 func GetTestDivisions(t *testing.T) {
@@ -81,25 +88,26 @@ func GetTestDivisions(t *testing.T) {
 
 func DeleteTestDivisions(t *testing.T) {
 
-       division := testData.Divisions[1]
-       // Retrieve the Division by name so we can get the id
-       resp, _, err := TOSession.GetDivisionByName(division.Name)
-       if err != nil {
-               t.Errorf("cannot GET Division by name: %v - %v\n", 
division.Name, err)
-       }
-       respDivision := resp[0]
+       for _, division := range testData.Divisions {
+               // Retrieve the Division by name so we can get the id
+               resp, _, err := TOSession.GetDivisionByName(division.Name)
+               if err != nil {
+                       t.Errorf("cannot GET Division by name: %v - %v\n", 
division.Name, err)
+               }
+               respDivision := resp[0]
 
-       delResp, _, err := TOSession.DeleteDivisionByID(respDivision.ID)
-       if err != nil {
-               t.Errorf("cannot DELETE Division by division: %v - %v\n", err, 
delResp)
-       }
+               delResp, _, err := TOSession.DeleteDivisionByID(respDivision.ID)
+               if err != nil {
+                       t.Errorf("cannot DELETE Division by division: %v - 
%v\n", err, delResp)
+               }
 
-       // Retrieve the Division to see if it got deleted
-       divisionResp, _, err := TOSession.GetDivisionByName(division.Name)
-       if err != nil {
-               t.Errorf("error deleting Division division: %s\n", err.Error())
-       }
-       if len(divisionResp) > 0 {
-               t.Errorf("expected Division : %s to be deleted\n", 
division.Name)
+               // Retrieve the Division to see if it got deleted
+               divisionResp, _, err := 
TOSession.GetDivisionByName(division.Name)
+               if err != nil {
+                       t.Errorf("error deleting Division division: %s\n", 
err.Error())
+               }
+               if len(divisionResp) > 0 {
+                       t.Errorf("expected Division : %s to be deleted\n", 
division.Name)
+               }
        }
 }
diff --git a/traffic_ops/testing/api/v13/phys_locations_test.go 
b/traffic_ops/testing/api/v13/phys_locations_test.go
index 6ef1e9987..cecf802dc 100644
--- a/traffic_ops/testing/api/v13/phys_locations_test.go
+++ b/traffic_ops/testing/api/v13/phys_locations_test.go
@@ -31,6 +31,9 @@ func TestPhysLocations(t *testing.T) {
        UpdateTestPhysLocations(t)
        GetTestPhysLocations(t)
        DeleteTestPhysLocations(t)
+       DeleteTestRegions(t)
+       DeleteTestDivisions(t)
+       DeleteTestCDNs(t)
 
 }
 
diff --git a/traffic_ops/testing/api/v13/regions_test.go 
b/traffic_ops/testing/api/v13/regions_test.go
index 4d3397aec..dac186d7e 100644
--- a/traffic_ops/testing/api/v13/regions_test.go
+++ b/traffic_ops/testing/api/v13/regions_test.go
@@ -25,11 +25,11 @@ import (
 func TestRegions(t *testing.T) {
 
        CreateTestDivisions(t)
-
        CreateTestRegions(t)
        UpdateTestRegions(t)
        GetTestRegions(t)
        DeleteTestRegions(t)
+       DeleteTestDivisions(t)
 
 }
 
@@ -80,6 +80,13 @@ func UpdateTestRegions(t *testing.T) {
                t.Errorf("results do not match actual: %s, expected: %s\n", 
respRegion.Name, expectedRegion)
        }
 
+       // Set the name back to the fixture value so we can delete it after
+       remoteRegion.Name = firstRegion.Name
+       alert, _, err = TOSession.UpdateRegionByID(remoteRegion.ID, 
remoteRegion)
+       if err != nil {
+               t.Errorf("cannot UPDATE Region by id: %v - %v\n", err, alert)
+       }
+
 }
 
 func GetTestRegions(t *testing.T) {
@@ -93,25 +100,26 @@ func GetTestRegions(t *testing.T) {
 
 func DeleteTestRegions(t *testing.T) {
 
-       region := testData.Regions[1]
-       // Retrieve the Region by name so we can get the id
-       resp, _, err := TOSession.GetRegionByName(region.Name)
-       if err != nil {
-               t.Errorf("cannot GET Region by name: %v - %v\n", region.Name, 
err)
-       }
-       respRegion := resp[0]
+       for _, region := range testData.Regions {
+               // Retrieve the Region by name so we can get the id
+               resp, _, err := TOSession.GetRegionByName(region.Name)
+               if err != nil {
+                       t.Errorf("cannot GET Region by name: %v - %v\n", 
region.Name, err)
+               }
+               respRegion := resp[0]
 
-       delResp, _, err := TOSession.DeleteRegionByID(respRegion.ID)
-       if err != nil {
-               t.Errorf("cannot DELETE Region by region: %v - %v\n", err, 
delResp)
-       }
+               delResp, _, err := TOSession.DeleteRegionByID(respRegion.ID)
+               if err != nil {
+                       t.Errorf("cannot DELETE Region by region: %v - %v\n", 
err, delResp)
+               }
 
-       // Retrieve the Region to see if it got deleted
-       regionResp, _, err := TOSession.GetRegionByName(region.Name)
-       if err != nil {
-               t.Errorf("error deleting Region region: %s\n", err.Error())
-       }
-       if len(regionResp) > 0 {
-               t.Errorf("expected Region : %s to be deleted\n", region.Name)
+               // Retrieve the Region to see if it got deleted
+               regionResp, _, err := TOSession.GetRegionByName(region.Name)
+               if err != nil {
+                       t.Errorf("error deleting Region region: %s\n", 
err.Error())
+               }
+               if len(regionResp) > 0 {
+                       t.Errorf("expected Region : %s to be deleted\n", 
region.Name)
+               }
        }
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to