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

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


The following commit(s) were added to refs/heads/master by this push:
     new c8f4b38b98 Fixes GetProfileID functions (#7061)
c8f4b38b98 is described below

commit c8f4b38b9800e78039c5ad1549b4ae6f8d7c7bfa
Author: Eric Holguin <[email protected]>
AuthorDate: Tue Sep 6 12:04:39 2022 -0600

    Fixes GetProfileID functions (#7061)
    
    * Fix GetProfileID functions
    
    * remove accidental change
---
 traffic_ops/testing/api/v3/deliveryservices_test.go | 10 +---------
 traffic_ops/testing/api/v3/servers_test.go          | 10 +++++-----
 traffic_ops/testing/api/v4/origins_test.go          |  4 ++--
 3 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/traffic_ops/testing/api/v3/deliveryservices_test.go 
b/traffic_ops/testing/api/v3/deliveryservices_test.go
index 82ce800585..bd4e994b67 100644
--- a/traffic_ops/testing/api/v3/deliveryservices_test.go
+++ b/traffic_ops/testing/api/v3/deliveryservices_test.go
@@ -323,7 +323,7 @@ func TestDeliveryServices(t *testing.T) {
                                        }
                                        if val, ok := 
testCase.RequestParams["profile"]; ok {
                                                if _, err := 
strconv.Atoi(val[0]); err != nil {
-                                                       
testCase.RequestParams.Set("profile", strconv.Itoa(GetProfileId(t, val[0])))
+                                                       
testCase.RequestParams.Set("profile", strconv.Itoa(GetProfileID(t, val[0])()))
                                                }
                                        }
                                        if val, ok := 
testCase.RequestParams["type"]; ok {
@@ -459,14 +459,6 @@ func GetDeliveryServiceId(t *testing.T, xmlId string) 
func() int {
        }
 }
 
-func GetProfileId(t *testing.T, profileName string) int {
-       resp, _, err := TOSession.GetProfileByNameWithHdr(profileName, 
http.Header{})
-       assert.RequireNoError(t, err, "Get Profiles Request failed with error: 
%v", err)
-       assert.RequireEqual(t, 1, len(resp), "Expected response object length 
1, but got %d", len(resp))
-       assert.RequireNotNil(t, &resp[0].ID, "Expected id to not be nil")
-       return resp[0].ID
-}
-
 func generateDeliveryService(t *testing.T, requestDS map[string]interface{}) 
map[string]interface{} {
        // map for the most basic HTTP Delivery Service a user can create
        genericHTTPDS := map[string]interface{}{
diff --git a/traffic_ops/testing/api/v3/servers_test.go 
b/traffic_ops/testing/api/v3/servers_test.go
index cd4d760985..39311ea146 100644
--- a/traffic_ops/testing/api/v3/servers_test.go
+++ b/traffic_ops/testing/api/v3/servers_test.go
@@ -82,7 +82,7 @@ func TestServers(t *testing.T) {
                                },
                                "OK when VALID PROFILEID parameter": {
                                        ClientSession: TOSession,
-                                       RequestParams: url.Values{"profileId": 
{strconv.Itoa(GetProfileId(t, "EDGE1"))}},
+                                       RequestParams: url.Values{"profileId": 
{strconv.Itoa(GetProfileID(t, "EDGE1")())}},
                                        Expectations:  
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK), 
utils.ResponseLengthGreaterOrEqual(1)),
                                },
                                "OK when VALID STATUS parameter": {
@@ -155,7 +155,7 @@ func TestServers(t *testing.T) {
                                                        "routerPort":     
"9004",
                                                }},
                                                "physLocationId": 
GetPhysicalLocationID(t, "Denver")(),
-                                               "profileId":      
GetProfileId(t, "EDGE1"),
+                                               "profileId":      
GetProfileID(t, "EDGE1")(),
                                                "rack":           "RR 119.03",
                                                "statusId":       
GetStatusID(t, "REPORTED")(),
                                                "tcpPort":        8080,
@@ -203,7 +203,7 @@ func TestServers(t *testing.T) {
                                        RequestBody: generateServer(t, 
map[string]interface{}{
                                                "id":           GetServerID(t, 
"midInTopologyMidCg01")(),
                                                "cdnId":        GetCDNID(t, 
"cdn1")(),
-                                               "profileId":    GetProfileId(t, 
"MID1"),
+                                               "profileId":    GetProfileID(t, 
"MID1")(),
                                                "cachegroupId": 
GetCacheGroupId(t, "topology-mid-cg-01")(),
                                        }),
                                        Expectations: 
utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusBadRequest)),
@@ -215,7 +215,7 @@ func TestServers(t *testing.T) {
                                                "id":           GetServerID(t, 
"midInTopologyMidCg01")(),
                                                "hostName":     
"midInTopologyMidCg01",
                                                "cdnId":        GetCDNID(t, 
"cdn2")(),
-                                               "profileId":    GetProfileId(t, 
"CDN2_MID"),
+                                               "profileId":    GetProfileID(t, 
"CDN2_MID")(),
                                                "cachegroupId": 
GetCacheGroupId(t, "topology-mid-cg-02")(),
                                        }),
                                        Expectations: 
utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusBadRequest)),
@@ -458,7 +458,7 @@ func generateServer(t *testing.T, requestServer 
map[string]interface{}) map[stri
                        "name": "eth0",
                }},
                "physLocationId": GetPhysicalLocationID(t, "Denver")(),
-               "profileId":      GetProfileId(t, "EDGE1"),
+               "profileId":      GetProfileID(t, "EDGE1")(),
                "statusId":       GetStatusID(t, "REPORTED")(),
                "typeId":         GetTypeId(t, "EDGE"),
        }
diff --git a/traffic_ops/testing/api/v4/origins_test.go 
b/traffic_ops/testing/api/v4/origins_test.go
index fadf6038d6..0d63525055 100644
--- a/traffic_ops/testing/api/v4/origins_test.go
+++ b/traffic_ops/testing/api/v4/origins_test.go
@@ -72,9 +72,9 @@ func TestOrigins(t *testing.T) {
                                },
                                "OK when VALID PROFILEID parameter": {
                                        ClientSession: TOSession,
-                                       RequestOpts:   
client.RequestOptions{QueryParameters: url.Values{"profileId": 
{strconv.Itoa(GetProfileId(t, "ATS_EDGE_TIER_CACHE"))}}},
+                                       RequestOpts:   
client.RequestOptions{QueryParameters: url.Values{"profileId": 
{strconv.Itoa(GetProfileID(t, "ATS_EDGE_TIER_CACHE")())}}},
                                        Expectations: 
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK), 
utils.ResponseLengthGreaterOrEqual(1),
-                                               
validateOriginsFields(map[string]interface{}{"ProfileID": GetProfileId(t, 
"ATS_EDGE_TIER_CACHE")})),
+                                               
validateOriginsFields(map[string]interface{}{"ProfileID": GetProfileID(t, 
"ATS_EDGE_TIER_CACHE")()})),
                                },
                                "OK when VALID PRIMARY parameter": {
                                        ClientSession: TOSession,

Reply via email to