ericholguin commented on a change in pull request #6690:
URL: https://github.com/apache/trafficcontrol/pull/6690#discussion_r838959511



##########
File path: traffic_ops/testing/api/v3/deliveryservices_test.go
##########
@@ -17,1180 +17,499 @@ package v3
 
 import (
        "encoding/json"
-       "fmt"
        "net/http"
        "net/url"
-       "reflect"
        "strconv"
-       "strings"
        "testing"
        "time"
 
        "github.com/apache/trafficcontrol/lib/go-rfc"
        "github.com/apache/trafficcontrol/lib/go-tc"
-       "github.com/apache/trafficcontrol/lib/go-util"
-       toclient "github.com/apache/trafficcontrol/traffic_ops/v3-client"
+       "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 TestDeliveryServices(t *testing.T) {
-       WithObjs(t, []TCObj{CDNs, Types, Tenants, Users, Parameters, Profiles, 
Statuses, Divisions, Regions, PhysLocations, CacheGroups, Servers, Topologies, 
ServerCapabilities, DeliveryServices}, func() {
-               currentTime := time.Now().UTC().Add(-5 * time.Second)
-               ti := currentTime.Format(time.RFC1123)
-               var header http.Header
-               header = make(map[string][]string)
-               header.Set(rfc.IfModifiedSince, ti)
-               header.Set(rfc.IfUnmodifiedSince, ti)
-               if includeSystemTests {
-                       SSLDeliveryServiceCDNUpdateTest(t)
-                       GetTestDeliveryServicesURLSigKeys(t)
+       WithObjs(t, []TCObj{CDNs, Types, Tenants, Users, Parameters, Profiles, 
Statuses, Divisions, Regions, PhysLocations, CacheGroups, Servers, Topologies, 
ServerCapabilities, DeliveryServices, DeliveryServicesRequiredCapabilities, 
DeliveryServiceServerAssignments}, func() {
+
+               tomorrow := time.Now().AddDate(0, 0, 1).Format(time.RFC1123)
+               currentTime := time.Now().UTC().Add(-15 * time.Second)
+               currentTimeRFC := currentTime.Format(time.RFC1123)
+
+               tenant4UserSession := utils.CreateV3Session(t, 
Config.TrafficOps.URL, "tenant4user", "pa$$word", 
Config.Default.Session.TimeoutInSecs)
+
+               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)),
+                               },
+                               "OK when ACTIVE=TRUE": {
+                                       ClientSession: TOSession, 
RequestParams: url.Values{"active": {"true"}},
+                                       Expectations: 
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK), 
utils.ResponseLengthGreaterOrEqual(1),
+                                               
validateGetDSExpectedFields(map[string]interface{}{"Active": true})),
+                               },
+                               "OK when ACTIVE=FALSE": {
+                                       ClientSession: TOSession, 
RequestParams: url.Values{"active": {"false"}},
+                                       Expectations: 
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK), 
utils.ResponseLengthGreaterOrEqual(1),
+                                               
validateGetDSExpectedFields(map[string]interface{}{"Active": false})),
+                               },
+                               "OK when VALID ACCESSIBLETO parameter": {
+                                       ClientSession: TOSession, 
RequestParams: url.Values{"accessibleTo": {"1"}},
+                                       Expectations: 
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK), 
utils.ResponseLengthGreaterOrEqual(1)),
+                               },
+                               "EMPTY RESPONSE when TENANT attempts reading DS 
OUTSIDE TENANCY": {
+                                       ClientSession: tenant4UserSession, 
RequestParams: url.Values{"xmlId": {"ds3"}},
+                                       Expectations: 
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK), 
utils.ResponseHasLength(0)),
+                               },
+                       },
+                       "POST": {

Review comment:
       No order does not matter. These tests also run randomly by default, 
goLang doesn't run table driven tests sequentially. I also run these tests on 
my end with the argument `-shuffle on` in order to make sure they don't overlap 
or can run without any dependency on other tests.




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