Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added HelloWorld test

  • Loading branch information...
commit 54be825a6924d318fe0939878a51dc1d6e206543 1 parent 254e6ee
@paulbellamy authored
Showing with 36 additions and 1 deletion.
  1. +1 −0  .gitignore
  2. +35 −1 mango_test.go
View
1  .gitignore
@@ -4,3 +4,4 @@
*.8
*.sw?
_obj
+_test*
View
36 mango_test.go
@@ -1 +1,35 @@
-package main
+package mango
+
+import (
+ "http"
+ "io/ioutil"
+ "testing"
+ "./mango"
+)
+
+func helloWorld(env mango.Env) (mango.Status, mango.Headers, mango.Body) {
+ return 200, make(map[string]string), mango.Body("Hello World!")
+}
+
+func TestHelloWorld(t *testing.T) {
+ // Start up the server
+ stack := new(mango.Stack)
+ stack.Address = "localhost:3000"
+ go stack.Run(helloWorld)
+
+ // Request against it
+ client := new(http.Client)
+ response, _, err := client.Get("http://localhost:3000/")
+ if err != nil {
+ t.Error(err)
+ }
+
+ if response.StatusCode != 200 {
+ t.Error("Expected status to equal 200, got:", response.StatusCode)
+ }
+
+ body, _ := ioutil.ReadAll(response.Body)
+ if string(body) != "Hello World!" {
+ t.Error("Expected body:", body, "to equal: \"Hello World!\"")
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.