srijeet0406 commented on a change in pull request #6003:
URL: https://github.com/apache/trafficcontrol/pull/6003#discussion_r710455567
##########
File path: traffic_ops/testing/api/v3/profiles_test.go
##########
@@ -269,10 +288,28 @@ func GetTestProfiles(t *testing.T) {
t.Errorf("cannot GET Profile by name: %v - %v", err,
resp)
}
profileID := resp[0].ID
-
- resp, _, err = TOSession.GetProfileByParameter(pr.Parameter)
- if err != nil {
- t.Errorf("cannot GET Profile by param: %v - %v", err,
resp)
+ if len(pr.Parameters) > 0 {
+ parameter := pr.Parameters[0]
+ respParameter, _, err :=
TOSession.GetParameterByName(*parameter.Name)
+ if err != nil {
Review comment:
same
##########
File path: traffic_ops/testing/api/v3/profiles_test.go
##########
@@ -83,12 +83,31 @@ func GetTestProfilesIMS(t *testing.T) {
if reqInf.StatusCode != http.StatusNotModified {
t.Fatalf("Expected 304 status code, got %v",
reqInf.StatusCode)
}
- _, reqInf, err =
TOSession.GetProfileByParameterWithHdr(pr.Parameter, header)
- if err != nil {
- t.Fatalf("Expected no error, but got %v", err.Error())
- }
- if reqInf.StatusCode != http.StatusNotModified {
- t.Fatalf("Expected 304 status code, got %v",
reqInf.StatusCode)
+ if len(pr.Parameters) > 0 {
+ parameter := pr.Parameters[0]
+ respParameter, _, err :=
TOSession.GetParameterByName(*parameter.Name)
+ if err != nil {
+ t.Errorf("Cannot GET Parameter by name: %v -
%v", err, respParameter)
Review comment:
Same.
##########
File path: traffic_ops/v2-client/profile.go
##########
@@ -178,6 +178,21 @@ func (to *Session) GetProfileByParameter(param string)
([]tc.Profile, ReqInf, er
return data.Response, reqInf, err
}
+func (to *Session) GetProfileByParameterId(param int) ([]tc.Profile, ReqInf,
error) {
Review comment:
Godoc is missing.
##########
File path: traffic_ops/testing/api/v2/profiles_test.go
##########
@@ -210,12 +210,29 @@ func GetTestProfiles(t *testing.T) {
t.Errorf("cannot GET Profile by name: %v - %v", err,
resp)
}
profileID := resp[0].ID
-
- resp, _, err = TOSession.GetProfileByParameter(pr.Parameter)
- if err != nil {
- t.Errorf("cannot GET Profile by param: %v - %v", err,
resp)
+ if len(pr.Parameters) > 0 {
+ parameter := pr.Parameters[0]
+ respParameter, _, err :=
TOSession.GetParameterByName(*parameter.Name)
+ if err != nil {
+ t.Errorf("Cannot GET Parameter by name: %v -
%v", err, resp)
Review comment:
This `resp` is the wrong response here. Also, I don't think you need to
print the response here, just the error is fine.
##########
File path: traffic_ops/testing/api/v4/profiles_test.go
##########
@@ -517,12 +517,31 @@ func GetTestProfiles(t *testing.T) {
}
profileID := resp.Response[0].ID
- // TODO: figure out what the 'Parameter' field of a Profile is
and how
- // passing it to this is supposed to work.
- // resp, _, err = TOSession.GetProfileByParameter(pr.Parameter)
- // if err != nil {
- // t.Errorf("cannot GET Profile by param: %v - %v", err,
resp)
- // }
+ if len(pr.Parameters) > 0 {
+ parameter := pr.Parameters[0]
+ opts.QueryParameters.Set("name", *parameter.Name)
+ respParameter, _, _ := TOSession.GetParameters(opts)
Review comment:
You should be checking the error here, as you are doing in the v2 and v3
tests.
##########
File path: traffic_ops/testing/api/v2/profiles_test.go
##########
@@ -210,12 +210,29 @@ func GetTestProfiles(t *testing.T) {
t.Errorf("cannot GET Profile by name: %v - %v", err,
resp)
}
profileID := resp[0].ID
-
- resp, _, err = TOSession.GetProfileByParameter(pr.Parameter)
- if err != nil {
- t.Errorf("cannot GET Profile by param: %v - %v", err,
resp)
+ if len(pr.Parameters) > 0 {
+ parameter := pr.Parameters[0]
+ respParameter, _, err :=
TOSession.GetParameterByName(*parameter.Name)
+ if err != nil {
+ t.Errorf("Cannot GET Parameter by name: %v -
%v", err, resp)
+ }
+ if len(respParameter) > 0 {
+ parameterID := respParameter[0].ID
+ if parameterID > 0 {
+ resp, _, err =
TOSession.GetProfileByParameterId(parameterID)
+ if err != nil {
+ t.Errorf("cannot GET Profile by
param: %v - %v", err, resp)
Review comment:
Same comment here, no need to print the response.
##########
File path: traffic_ops/v3-client/profile.go
##########
@@ -139,6 +139,19 @@ func (to *Session) GetProfileByParameter(param string)
([]tc.Profile, toclientli
return to.GetProfileByParameterWithHdr(param, nil)
}
+func (to *Session) GetProfileByParameterIdWithHdr(param int, header
http.Header) ([]tc.Profile, toclientlib.ReqInf, error) {
Review comment:
Godoc is missing.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]