You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2020/01/13 20:43:36 UTC

[GitHub] [trafficcontrol] rob05c commented on a change in pull request #3862: Add Traffic Ops /deliveryservices, /servers If-Modified-Since support

rob05c commented on a change in pull request #3862: Add Traffic Ops /deliveryservices, /servers If-Modified-Since support
URL: https://github.com/apache/trafficcontrol/pull/3862#discussion_r366017952
 
 

 ##########
 File path: traffic_ops/testing/api/v14/deliveryservice_ims_test.go
 ##########
 @@ -0,0 +1,277 @@
+package v14
+
+/*
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+*/
+
+import (
+	"net/http"
+	"strconv"
+	"testing"
+	"time"
+
+	"github.com/apache/trafficcontrol/lib/go-rfc"
+	"github.com/apache/trafficcontrol/lib/go-tc"
+)
+
+func TestDeliveryServiceIMS(t *testing.T) {
+	WithObjs(t, []TCObj{CDNs, Types, Tenants, Users, Parameters, Profiles, Statuses, Divisions, Regions, PhysLocations, CacheGroups, Servers, DeliveryServices}, func() {
+		GetTestDeliveryServiceIMSAll(t)
+		GetTestDeliveryServiceIMSSingle(t)
+	})
+}
+
+func GetTestDeliveryServiceIMSAll(t *testing.T) {
+	req, err := http.NewRequest(http.MethodGet, TOSession.URL+"/api/1.4/deliveryservices", nil)
+	if err != nil {
+		t.Fatalf("failed to create request: %s", err.Error())
+	}
+
+	resp, err := TOSession.Client.Do(req)
+	if err != nil {
+		t.Fatalf("running request: %s", err.Error())
+	}
+	resp.Body.Close()
+
+	lastModified := resp.Header.Get(rfc.HdrLastModified)
+	if lastModified == "" {
+		t.Fatalf("deliveryservices request expected: " + rfc.HdrLastModified + " header, actual: missing")
+	}
+
+	etag := resp.Header.Get(rfc.HdrETag)
+	if etag == "" {
+		t.Fatalf("deliveryservices request expected: " + rfc.HdrETag + " header, actual: missing")
+	}
+
+	{
 
 Review comment:
   It makes `req`, `resp`, and `err` new variables, rather than reusing existing ones. The point is to make copy-paste bugs impossible, where a variable was re-used accidentally. The above should really be in its own block, too, to make it a compile error to use the earlier variables in the lower block.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services