File tree 2 files changed +36
-1
lines changed
2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change 4
4
* .8
5
5
* .sw ?
6
6
_obj
7
+ _test *
Original file line number Diff line number Diff line change 1
- package main
1
+ package mango
2
+
3
+ import (
4
+ "http"
5
+ "io/ioutil"
6
+ "testing"
7
+ "./mango"
8
+ )
9
+
10
+ func helloWorld (env mango.Env ) (mango.Status , mango.Headers , mango.Body ) {
11
+ return 200 , make (map [string ]string ), mango .Body ("Hello World!" )
12
+ }
13
+
14
+ func TestHelloWorld (t * testing.T ) {
15
+ // Start up the server
16
+ stack := new (mango.Stack )
17
+ stack .Address = "localhost:3000"
18
+ go stack .Run (helloWorld )
19
+
20
+ // Request against it
21
+ client := new (http.Client )
22
+ response , _ , err := client .Get ("http://localhost:3000/" )
23
+ if err != nil {
24
+ t .Error (err )
25
+ }
26
+
27
+ if response .StatusCode != 200 {
28
+ t .Error ("Expected status to equal 200, got:" , response .StatusCode )
29
+ }
30
+
31
+ body , _ := ioutil .ReadAll (response .Body )
32
+ if string (body ) != "Hello World!" {
33
+ t .Error ("Expected body:" , body , "to equal: \" Hello World!\" " )
34
+ }
35
+ }
You can’t perform that action at this time.
0 commit comments