rob05c commented on a change in pull request #5328:
URL: https://github.com/apache/trafficcontrol/pull/5328#discussion_r535706219
##########
File path: traffic_ops/testing/api/v3/deliveryserviceservers_test.go
##########
@@ -17,21 +17,339 @@ package v3
import (
"errors"
+ "fmt"
"net/http"
"net/url"
"strconv"
"strings"
"testing"
+ "time"
"github.com/apache/trafficcontrol/lib/go-tc"
"github.com/apache/trafficcontrol/lib/go-util"
)
+func TryToRemoveLastServerInDeliveryService(t *testing.T) {
+ cdns, _, err := TOSession.GetCDNsWithHdr(nil)
+ if err != nil {
+ t.Fatalf("Could not fetch CDNs: %v", err)
+ }
+ if len(cdns) < 1 {
+ t.Fatal("Need at least one CDN to test removing the last server
from a Delivery Service")
+ }
+
+ cdnID := cdns[0].ID
+
+ user, _, err := TOSession.GetUserCurrentWithHdr(nil)
+ if err != nil {
+ t.Fatalf("Could not fetch current user: %v", err)
+ }
+ if user == nil {
+ t.Fatalf("Current user is null")
+ }
+ if user.TenantID == nil {
+ t.Fatalf("Current user has null Tenant ID")
+ }
+
+ types, _, err := TOSession.GetTypesWithHdr(nil, "deliveryservice")
+ if err != nil {
+ t.Fatalf("Could not fetch Types: %v", err)
+ }
+ if len(types) < 1 {
+ t.Fatal("Need at least one Type with 'useInTable' of
'deliveryservice' to create a Delivery Service")
+ }
+ dsTypeID := types[0].ID
+
+ xmlid := fmt.Sprintf("test-%d", time.Now().Unix())
+ ds := tc.DeliveryServiceNullableV30{
Review comment:
+1
It also has the benefit of not breaking if the internal embedded-type
structure of `tc.DeliveryServiceNullableV30` changes.
----------------------------------------------------------------
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]