rimashah25 commented on code in PR #6950:
URL: https://github.com/apache/trafficcontrol/pull/6950#discussion_r922393595


##########
traffic_ops/testing/api/v3/servicecategories_test.go:
##########
@@ -24,221 +25,203 @@ import (
 
        "github.com/apache/trafficcontrol/lib/go-rfc"
        "github.com/apache/trafficcontrol/lib/go-tc"
+       "github.com/apache/trafficcontrol/traffic_ops/testing/api/assert"
+       "github.com/apache/trafficcontrol/traffic_ops/testing/api/utils"
+       "github.com/apache/trafficcontrol/traffic_ops/toclientlib"
 )
 
 func TestServiceCategories(t *testing.T) {
        WithObjs(t, []TCObj{ServiceCategories}, func() {
-               GetTestServiceCategoriesIMS(t)
-               currentTime := time.Now().UTC().Add(-5 * time.Second)
-               time := currentTime.Format(time.RFC1123)
-               var header http.Header
-               header = make(map[string][]string)
-               header.Set(rfc.IfModifiedSince, time)
-               header.Set(rfc.IfUnmodifiedSince, time)
-               SortTestServiceCategories(t)
-               UpdateTestServiceCategories(t)
-               GetTestServiceCategories(t)
-               GetTestServiceCategoriesIMSAfterChange(t, header)
-               UpdateTestServiceCategoriesWithHeaders(t, header)
-               header = make(map[string][]string)
-               etag := rfc.ETag(currentTime)
-               header.Set(rfc.IfMatch, etag)
-               UpdateTestServiceCategoriesWithHeaders(t, header)
-       })
-}
 
-func GetTestServiceCategoriesIMS(t *testing.T) {
-       var header http.Header
-       header = make(map[string][]string)
-       futureTime := time.Now().AddDate(0, 0, 1)
-       time := futureTime.Format(time.RFC1123)
-       header.Set(rfc.IfModifiedSince, time)
-       params := url.Values{}
-       for _, sc := range testData.ServiceCategories {
-               params.Add("name", sc.Name)
-               _, reqInf, err := 
TOSession.GetServiceCategoriesWithHdr(&params, 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)
+               currentTime := time.Now().UTC().Add(-15 * time.Second)
+               currentTimeRFC := currentTime.Format(time.RFC1123)
+               tomorrow := currentTime.AddDate(0, 0, 1).Format(time.RFC1123)
+
+               methodTests := utils.V3TestCase{
+                       "GET": {
+                               "NOT MODIFIED when NO CHANGES made": {
+                                       ClientSession:  TOSession,
+                                       RequestHeaders: 
http.Header{rfc.IfModifiedSince: {tomorrow}},
+                                       Expectations:   
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusNotModified)),
+                               },
+                               "OK when VALID request": {
+                                       ClientSession: TOSession,
+                                       Expectations:  
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK), 
validateServiceCategoriesSort()),
+                               },
+                               "OK when VALID NAME parameter": {
+                                       ClientSession: TOSession,
+                                       RequestParams: url.Values{"name": 
{"serviceCategory1"}},
+                                       Expectations: 
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK), 
utils.ResponseLengthGreaterOrEqual(1),
+                                               
validateServiceCategoriesFields(map[string]interface{}{"Name": 
"serviceCategory1"})),
+                               },
+                               "EMPTY RESPONSE when SERVICE CATEGORY DOESNT 
EXIST": {

Review Comment:
   This check is currently not existing in V3 test cases but is good to have.



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

Reply via email to