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

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


The following commit(s) were added to refs/heads/master by this push:
     new ae735dc  cleaned up the teardown functions so each test case works as 
a unit
ae735dc is described below

commit ae735dc42896f7b97042399d1822b083a765514d
Author: Dewayne Richardson <dewr...@apache.org>
AuthorDate: Wed Apr 11 11:42:48 2018 -0600

    cleaned up the teardown functions so each test case works as a unit
---
 .../client/v13/deliveryservice_request_comments.go |  3 --
 .../v13/deliveryservice_request_comments_test.go   |  4 +-
 traffic_ops/testing/api/v13/divisions_test.go      | 44 ++++++++++++---------
 traffic_ops/testing/api/v13/phys_locations_test.go |  3 ++
 traffic_ops/testing/api/v13/regions_test.go        | 46 +++++++++++++---------
 5 files changed, 57 insertions(+), 43 deletions(-)

diff --git a/traffic_ops/client/v13/deliveryservice_request_comments.go 
b/traffic_ops/client/v13/deliveryservice_request_comments.go
index 02e0763..f8389b6 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 55968e0..cc6ba96 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"
 )
 
@@ -51,9 +50,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 954fe7f..b2c524d 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 6ef1e99..cecf802 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 4d3397a..dac186d 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)
+               }
        }
 }

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

Reply via email to