From 7ec047033d8666d5c2cf27f2e99a7887b59c6921 Mon Sep 17 00:00:00 2001
From: Will McCutchen <will@mccutch.org>
Date: Fri, 16 Jun 2017 15:56:37 -0700
Subject: [PATCH] More test fixes

---
 httpbin/handlers.go      | 16 ----------------
 httpbin/handlers_test.go |  4 +++-
 2 files changed, 3 insertions(+), 17 deletions(-)

diff --git a/httpbin/handlers.go b/httpbin/handlers.go
index 58f0579..701211c 100644
--- a/httpbin/handlers.go
+++ b/httpbin/handlers.go
@@ -23,10 +23,6 @@ var acceptedMediaTypes = []string{
 	"image/",
 }
 
-func notImplementedHandler(w http.ResponseWriter, r *http.Request) {
-	http.Error(w, "Not implemented", http.StatusNotImplemented)
-}
-
 // Index renders an HTML index page
 func (h *HTTPBin) Index(w http.ResponseWriter, r *http.Request) {
 	if r.URL.Path != "/" {
@@ -597,18 +593,6 @@ func (h *HTTPBin) Cache(w http.ResponseWriter, r *http.Request) {
 		return
 	}
 
-	// Did we get an additional /cache/N path parameter? If so, validate it
-	// and set the Cache-Control header.
-	parts := strings.Split(r.URL.Path, "/")
-	if len(parts) == 3 {
-		seconds, err := strconv.ParseInt(parts[2], 10, 64)
-		if err != nil {
-			http.Error(w, err.Error(), http.StatusBadRequest)
-			return
-		}
-		w.Header().Add("Cache-Control", fmt.Sprintf("public, max-age=%d", seconds))
-	}
-
 	lastModified := time.Now().Format(time.RFC1123)
 	w.Header().Add("Last-Modified", lastModified)
 	w.Header().Add("ETag", sha1hash(lastModified))
diff --git a/httpbin/handlers_test.go b/httpbin/handlers_test.go
index 46cb62f..73a450f 100644
--- a/httpbin/handlers_test.go
+++ b/httpbin/handlers_test.go
@@ -1720,7 +1720,7 @@ func TestCacheControl(t *testing.T) {
 		{"/cache/3.14", http.StatusBadRequest},
 	}
 	for _, test := range badTests {
-		t.Run(fmt.Sprintf("bad/%s", test.url), func(t *testing.T) {
+		t.Run("bad"+test.url, func(t *testing.T) {
 			r, _ := http.NewRequest("GET", test.url, nil)
 			w := httptest.NewRecorder()
 			handler.ServeHTTP(w, r)
@@ -1945,6 +1945,8 @@ func TestLinks(t *testing.T) {
 		url            string
 		expectedStatus int
 	}{
+		{"/links/10/1/foo", http.StatusNotFound},
+
 		// invalid N
 		{"/links/3.14", http.StatusBadRequest},
 		{"/links/-1", http.StatusBadRequest},
-- 
GitLab