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


##########
traffic_ops/testing/api/v3/deliveryservice_request_comments_test.go:
##########
@@ -16,189 +16,178 @@ package v3
 */
 
 import (
+       "encoding/json"
        "net/http"
        "sort"
        "testing"
        "time"
 
        "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 TestDeliveryServiceRequestComments(t *testing.T) {
        WithObjs(t, []TCObj{CDNs, Types, Parameters, Tenants, 
DeliveryServiceRequests, DeliveryServiceRequestComments}, func() {
-               GetTestDeliveryServiceRequestCommentsIMS(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.IfUnmodifiedSince, time)
-               header.Set(rfc.IfModifiedSince, time)
-               SortTestDeliveryServiceRequestComments(t)
-               UpdateTestDeliveryServiceRequestComments(t)
-               UpdateTestDeliveryServiceRequestCommentsWithHeaders(t, header)
-               header = make(map[string][]string)
-               etag := rfc.ETag(currentTime)
-               header.Set(rfc.IfMatch, etag)
-               UpdateTestDeliveryServiceRequestCommentsWithHeaders(t, header)
-               GetTestDeliveryServiceRequestComments(t)
-               GetTestDeliveryServiceRequestCommentsIMSAfterChange(t, header)
-       })
-}
-
-func UpdateTestDeliveryServiceRequestCommentsWithHeaders(t *testing.T, header 
http.Header) {
-       comments, _, _ := 
TOSession.GetDeliveryServiceRequestCommentsWithHdr(header)
 
-       if len(comments) > 0 {
-               firstComment := comments[0]
-               newFirstCommentValue := "new comment value"
-               firstComment.Value = newFirstCommentValue
-
-               _, reqInf, err := 
TOSession.UpdateDeliveryServiceRequestCommentByIDWithHdr(firstComment.ID, 
firstComment, header)
-               if err == nil {
-                       t.Errorf("expected precondition failed error, but got 
none")
-               }
-               if reqInf.StatusCode != http.StatusPreconditionFailed {
-                       t.Errorf("Expected status code 412, 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": {

Review Comment:
   nit: Is there a reason why each field of V3TestData struct is sometimes 
starting on a new line and sometimes it is not? Can we chose one option for 
clarity (for eg: new line)?



##########
traffic_ops/testing/api/v4/deliveryservice_request_comments_test.go:
##########
@@ -16,228 +16,184 @@ package v4
 */
 
 import (
+       "encoding/json"
        "net/http"
+       "net/url"
        "sort"
        "strconv"
        "testing"
        "time"
 
        "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"
        client "github.com/apache/trafficcontrol/traffic_ops/v4-client"
 )
 
 func TestDeliveryServiceRequestComments(t *testing.T) {
        WithObjs(t, []TCObj{CDNs, Types, Parameters, Tenants, 
DeliveryServiceRequests, DeliveryServiceRequestComments}, func() {
-               GetTestDeliveryServiceRequestCommentsIMS(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.IfUnmodifiedSince, time)
-               header.Set(rfc.IfModifiedSince, time)
-               SortTestDeliveryServiceRequestComments(t)
-               UpdateTestDeliveryServiceRequestComments(t)
-               UpdateTestDeliveryServiceRequestCommentsWithHeaders(t, header)
-               header = make(map[string][]string)
-               etag := rfc.ETag(currentTime)
-               header.Set(rfc.IfMatch, etag)
-               UpdateTestDeliveryServiceRequestCommentsWithHeaders(t, header)
-               GetTestDeliveryServiceRequestComments(t)
-               GetTestDeliveryServiceRequestCommentsIMSAfterChange(t, header)
-       })
-}
-
-func UpdateTestDeliveryServiceRequestCommentsWithHeaders(t *testing.T, header 
http.Header) {
-       opts := client.NewRequestOptions()
-       opts.Header = header
-       comments, _, _ := TOSession.GetDeliveryServiceRequestComments(opts)
-
-       if len(comments.Response) > 0 {
-               firstComment := comments.Response[0]
-               newFirstCommentValue := "new comment value"
-               firstComment.Value = newFirstCommentValue
 
-               _, reqInf, err := 
TOSession.UpdateDeliveryServiceRequestComment(firstComment.ID, firstComment, 
opts)
-               if err == nil {
-                       t.Errorf("expected precondition failed error, but got 
none")
+               currentTime := time.Now().UTC().Add(-15 * time.Second)
+               currentTimeRFC := currentTime.Format(time.RFC1123)
+               tomorrow := currentTime.AddDate(0, 0, 1).Format(time.RFC1123)
+
+               methodTests := utils.V4TestCase{
+                       "GET": {

Review Comment:
   nit: 
   Is there a reason why each field of V4TestData struct is sometimes starting 
on a new line and sometimes it is not? Can we chose one option for clarity (for 
eg: start each field on a new line)?



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