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



##########
File path: traffic_ops/testing/api/v4/deliveryservices_test.go
##########
@@ -1238,6 +1254,272 @@ func VerifyPaginationSupportDS(t *testing.T) {
        }
 }
 
+func GetDeliveryServiceByCdn(t *testing.T) {
+
+       if len(testData.DeliveryServices) > 0 {
+               firstDS := testData.DeliveryServices[0]
+
+               if firstDS.CDNID == nil && firstDS.CDNName != nil {
+                       cdns, _, err := 
TOSession.GetCDNByNameWithHdr(*firstDS.CDNName, nil)
+                       if err != nil {
+                               t.Fatalf("Error in Getting CDN by Name: %v", 
err)
+                       }
+                       if len(cdns) == 0 {
+                               t.Fatalf("no CDN named %v" + *firstDS.CDNName)
+                       }
+                       firstDS.CDNID = &cdns[0].ID
+               }
+               resp, _, err := 
TOSession.GetDeliveryServicesByCDNIDWithHdr(*firstDS.CDNID, nil)
+               if err != nil {
+                       t.Fatalf("Error in Getting DeliveryServices by CDN ID: 
%v - %v", err, resp)
+               }
+               if len(resp) == 0 {
+                       t.Errorf("No delivery service available for the CDN 
%v", *firstDS.CDNName)
+               } else {
+                       if *resp[0].CDNName != *firstDS.CDNName {
+                               t.Fatalf("CDN Name expected: %s, actual: %s", 
*firstDS.CDNName, *resp[0].CDNName)
+                       }
+               }
+       }
+}
+
+func GetDeliveryServiceByInvalidCdn(t *testing.T) {
+       resp, _, err := TOSession.GetDeliveryServicesByCDNIDWithHdr(10000, nil)
+       if err != nil {
+               t.Fatalf("Error!! Getting CDN by Invalid ID %v", err)
+       }
+       if len(resp) >= 1 {
+               t.Fatalf("Error!! Invalid CDN shouldn't have any response %v 
Error %v", resp, err)
+       }
+}
+
+func GetDeliveryServiceByLogsEnabled(t *testing.T) {
+       if len(testData.DeliveryServices) > 0 {
+               firstDS := testData.DeliveryServices[0]
+
+               qparams := url.Values{}
+               qparams.Set("logsEnabled", 
strconv.FormatBool(*firstDS.LogsEnabled))
+               resp, _, err := TOSession.GetDeliveryServicesV4(nil, qparams)
+               if err != nil {
+                       t.Fatalf("Error in Getting deliveryservice by 
logsEnabled: %v - %v", err, resp)
+               }
+               if len(resp) == 0 {
+                       t.Errorf("No delivery service available for the Logs 
Enabled %v", *firstDS.LogsEnabled)
+               } else {
+                       if *resp[0].LogsEnabled != *firstDS.LogsEnabled {
+                               t.Fatalf("name expected: %t, actual: %t", 
*firstDS.LogsEnabled, *resp[0].LogsEnabled)

Review comment:
       Handled Null values.




-- 
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:
[email protected]


Reply via email to