Skip to content
Snippets Groups Projects
Commit 7ec04703 authored by Will McCutchen's avatar Will McCutchen
Browse files

More test fixes

parent 11413679
No related branches found
No related tags found
No related merge requests found
......@@ -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))
......
......@@ -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},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment