You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2021/05/27 17:37:02 UTC

[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #5889: Add TO Client API for Cachegroup Automation

ocket8888 commented on a change in pull request #5889:
URL: https://github.com/apache/trafficcontrol/pull/5889#discussion_r640832894



##########
File path: traffic_ops/testing/api/v4/cachegroups_test.go
##########
@@ -835,3 +839,68 @@ func GetTestPaginationSupportCg(t *testing.T) {
 		t.Errorf("expected GET cachegroup to return an error for page is not a positive integer, actual error: %v - alerts: %+v", err, resp.Alerts)
 	}
 }
+
+func GetTestCacheGroupsByInvalidId(t *testing.T) {
+	opts := client.NewRequestOptions()
+	// Retrieve the CacheGroup to check CacheGroup name got updated
+	opts.QueryParameters.Set("id", "10000")
+	resp, _, _ := TOSession.GetCacheGroups(opts)
+	if len(resp.Response) > 0 {
+		t.Errorf("Expected 0 response, but got many %v", resp)
+	}
+}
+
+func GetTestCacheGroupsByInvalidType(t *testing.T) {
+	opts := client.NewRequestOptions()
+	// Retrieve the CacheGroup to check CacheGroup name got updated
+	opts.QueryParameters.Set("type", "10000")
+	resp, _, _ := TOSession.GetCacheGroups(opts)
+	if len(resp.Response) > 0 {
+		t.Errorf("Expected 0 response, but got many %v", resp)
+	}
+}
+
+func GetTestCacheGroupsByType(t *testing.T) {
+	if len(testData.CacheGroups) < 1 {
+		t.Fatal("Need at least one Cache Group to test updating Cache Groups")
+	}
+	firstCG := testData.CacheGroups[0]
+
+	if firstCG.Name == nil {
+		t.Fatal("Found Cache Group with null or undefined name in testing data")
+	}
+
+	opts := client.NewRequestOptions()
+	opts.QueryParameters.Set("name", *firstCG.Name)
+
+	resp, _, err := TOSession.GetCacheGroups(opts)
+	if err != nil {
+		t.Fatalf("cannot get Cache Group '%s': %v - alerts: %+v", *firstCG.Name, err, resp.Alerts)
+	}
+	if len(resp.Response) < 1 {
+		t.Fatalf("Expected exactly one Cache Group to exist with name '%s', but got: %d", *firstCG.Name, len(resp.Response))

Review comment:
       If the expectation is that "exactly one" exists, the condition should check for the length being exactly one or not, instead of merely less than one.




-- 
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:
users@infra.apache.org