ocket8888 commented on a change in pull request #3900: Rewrite 
/cachegroups/{{id}}/parameters to Go
URL: https://github.com/apache/trafficcontrol/pull/3900#discussion_r320755402
 
 

 ##########
 File path: traffic_ops/testing/api/v14/cachegroups_parameters_test.go
 ##########
 @@ -0,0 +1,91 @@
+// /*
+
+//  Licensed under the Apache License, Version 2.0 (the "License");
+//  you may not use this file except in compliance with the License.
+//  You may obtain a copy of the License at
+
+//  http://www.apache.org/licenses/LICENSE-2.0
+
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+// */
+
+package v14
+
+import (
+       "fmt"
+       "testing"
+
+       "github.com/apache/trafficcontrol/lib/go-tc"
+
+       "github.com/apache/trafficcontrol/lib/go-log"
+)
+
+func TestCacheGroupParameters(t *testing.T) {
+       WithObjs(t, []TCObj{Types, Parameters, CacheGroups}, func() {
+               GetTestCacheGroupParameters(t)
+       })
+}
+
+func CreateTestCacheGroupParameters(t *testing.T) {
+
+       firstCacheGroup := testData.CacheGroups[0]
+       cacheGroupResp, _, err := 
TOSession.GetCacheGroupByName(*firstCacheGroup.Name)
+       if err != nil {
+               t.Errorf("cannot GET Cache Group by name: %v - %v\n", 
firstCacheGroup.Name, err)
+       }
+
+       firstParameter := testData.Parameters[0]
+       paramResp, _, err := TOSession.GetParameterByName(firstParameter.Name)
+       if err != nil {
+               t.Errorf("cannot GET Parameter by name: %v - %v\n", 
firstParameter.Name, err)
+       }
+
+       cacheGroupID := cacheGroupResp[0].ID
+       parameterID := paramResp[0].ID
+
+       resp, _, err := TOSession.CreateCacheGroupParameter(cacheGroupID, 
parameterID)
+       log.Debugln("Response: ", resp)
+       if err != nil {
+               t.Errorf("could not CREATE cache group parameter: %v\n", err)
+       }
+       testData.CacheGroupParameters = append(testData.CacheGroupParameters, 
resp.Response...)
+}
+
+func GetTestCacheGroupParameters(t *testing.T) {
+       for _, cgp := range testData.CacheGroupParameters {
+               resp, _, err := TOSession.GetCacheGroupParameters(cgp.ID)
+               if err != nil {
+                       t.Errorf("cannot GET Parameter by cache group: %v - 
%v\n", err, resp)
+               }
+       }
+}
+
+func DeleteTestCacheGroupParameters(t *testing.T) {
+       for _, cgp := range testData.CacheGroupParameters {
+               DeleteTestCacheGroupParameter(t, cgp)
+       }
+}
+
+func DeleteTestCacheGroupParameter(t *testing.T, cgp tc.CacheGroupParameter) {
+
+       delResp, _, err := TOSession.DeleteCacheGroupParameter(cgp.ID, 
cgp.ParameterID)
+       if err != nil {
+               t.Errorf("cannot DELETE Parameter by cache group: %v - %v\n", 
err, delResp)
+       }
+
+       // Retrieve the Cache Group Parameter to see if it got deleted
+       queryParams := fmt.Sprintf("parameterId=%d", cgp.ParameterID)
+
+       parameters, _, err := 
TOSession.GetCacheGroupParametersByQueryParams(cgp.ID, queryParams)
 
 Review comment:
   Same as above RE `nil` response.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to