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/28 03:41:28 UTC

[GitHub] [trafficcontrol] dmohan001c commented on a change in pull request #5885: Add TO Client API for Service Categories Automation

dmohan001c commented on a change in pull request #5885:
URL: https://github.com/apache/trafficcontrol/pull/5885#discussion_r641228391



##########
File path: traffic_ops/testing/api/v4/servicecategories_test.go
##########
@@ -104,6 +112,34 @@ func CreateTestServiceCategories(t *testing.T) {
 	}
 }
 
+func CreateTestServiceCategoriesAlreadyExist(t *testing.T) {
+	firstServiceCategory := tc.ServiceCategory{}
+	if len(testData.ServiceCategories) > 0 {
+		firstServiceCategory = testData.ServiceCategories[0]
+	} else {
+		t.Fatalf("cannot CREATE DUPLICATE Service Category, test data does not have service categories")
+	}
+	resp, reqInf, err := TOSession.CreateServiceCategory(firstServiceCategory, client.RequestOptions{})
+	if err == nil {
+		t.Errorf("Expected service_category name already exists. but got: %v - alerts: %+v", err, resp.Alerts)
+	}
+	if reqInf.StatusCode != http.StatusBadRequest {
+		t.Fatalf("Expected 400 status code, got %v", reqInf.StatusCode)
+	}
+}
+
+func CreateTestServiceCategoriesInvalidName(t *testing.T) {
+	firstServiceCategory := tc.ServiceCategory{}
+	firstServiceCategory.Name = ""
+	resp, reqInf, err := TOSession.CreateServiceCategory(firstServiceCategory, client.RequestOptions{})
+	if err == nil {
+		t.Errorf("Expected service_category name already exists. but got: %v - alerts: %+v", err, resp.Alerts)

Review comment:
       updated error message.




-- 
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