Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(58)

Unified Diff: testing/httpsuite/httpsuite_test.go

Issue 6844087: goose: all current code
Patch Set: Created 12 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: testing/httpsuite/httpsuite_test.go
=== added file 'testing/httpsuite/httpsuite_test.go'
--- testing/httpsuite/httpsuite_test.go 1970-01-01 00:00:00 +0000
+++ testing/httpsuite/httpsuite_test.go 2012-11-14 12:29:18 +0000
@@ -0,0 +1,39 @@
+package httpsuite
+
+import (
+ "io/ioutil"
+ . "launchpad.net/gocheck"
+ "net/http"
+ "testing"
+)
+
+type HTTPTestSuite struct {
+ HTTPSuite
+}
+
+func Test(t *testing.T) {
+ TestingT(t)
+}
+
+var _ = Suite(&HTTPTestSuite{})
+
+type HelloHandler struct{}
+
+func (h *HelloHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+ w.Header().Set("Content-Type", "text/plain")
+ w.WriteHeader(200)
+ w.Write([]byte("Hello World\n"))
+}
+
+func (s *HTTPTestSuite) TestHelloWorld(c *C) {
+ s.Mux.Handle("/", &HelloHandler{})
+ // fmt.Printf("Running HelloWorld\n")
+ response, err := http.Get(s.Server.URL)
+ c.Check(err, IsNil)
+ content, err := ioutil.ReadAll(response.Body)
+ response.Body.Close()
+ c.Check(err, IsNil)
+ c.Check(response.Status, Equals, "200 OK")
+ c.Check(response.StatusCode, Equals, 200)
+ c.Check(string(content), Equals, "Hello World\n")
+}

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b