Browse Source

Remove TODOs from TestServerWithCurl; make it send a body too

Brad Fitzpatrick 11 years ago
parent
commit
162751004b
1 changed files with 6 additions and 13 deletions
  1. 6 13
      server_test.go

+ 6 - 13
server_test.go

@@ -1170,21 +1170,10 @@ func testServerResponse(t *testing.T,
 
 func TestServerWithCurl(t *testing.T) {
 	requireCurl(t)
-
+	const msg = "Hello from curl!\n"
 	ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
-		// TODO: add a bunch of different tests with different
-		// behavior, as a function of r or a table.
-		// -- with request body, without.
-		// -- no interaction with w.
-		// -- panic
-		// -- modify Header only, but no writes or writeheader (this test)
-		// -- WriteHeader only
-		// -- Write only
-		// -- WriteString
-		// -- both
-		// -- huge headers over a frame size so we get continuation headers.
-		// Look at net/http's Server tests for inspiration.
 		w.Header().Set("Foo", "Bar")
+		io.WriteString(w, msg)
 	}))
 	ConfigureServer(ts.Config, &Server{})
 	ts.TLS = ts.Config.TLSConfig // the httptest.Server has its own copy of this TLS config
@@ -1215,6 +1204,10 @@ func TestServerWithCurl(t *testing.T) {
 			t.Errorf("didn't see foo:Bar header")
 			t.Logf("Got: %s", res)
 		}
+		if !strings.Contains(string(res.([]byte)), msg) {
+			t.Errorf("didn't see %q content", msg)
+			t.Logf("Got: %s", res)
+		}
 	case <-time.After(3 * time.Second):
 		t.Errorf("timeout waiting for curl")
 	}