diff options
| author | Horus_Arch | 2015-02-23 12:13:32 +0100 |
|---|---|---|
| committer | Horus_Arch | 2015-02-23 12:13:32 +0100 |
| commit | 70d080b69a1bce3125d8d0b83e23775880241763 (patch) | |
| tree | 6fac80f9291e361045098b2ce9eb0839652e6b42 /app/handler_test.go | |
| parent | 00b28812fb5ab68156ead5b45b66740a4d5ca688 (diff) | |
| download | statuspage-70d080b69a1bce3125d8d0b83e23775880241763.tar.gz | |
Refactor and more unit tests.
Diffstat (limited to 'app/handler_test.go')
| -rw-r--r-- | app/handler_test.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/app/handler_test.go b/app/handler_test.go new file mode 100644 index 0000000..67692b0 --- /dev/null +++ b/app/handler_test.go @@ -0,0 +1,35 @@ +// +build all dep + +package main + +import ( + "net/http" + "net/http/httptest" + "testing" +) + +func TestIndexHandler(t *testing.T) { + request, err := http.NewRequest("GET", "/", nil) + if err != nil { + t.Log("Error creating new http request. ", err) + } + response := httptest.NewRecorder() + + IndexHandler(response, request) + + if response.Code != 200 { + t.Log(response.Code) + t.Fatal("Expected 200 as status code.") + } +} + +func BenchmarkIndexHandler(b *testing.B) { + b.StopTimer() + request, _ := http.NewRequest("GET", "/", nil) + response := httptest.NewRecorder() + + b.StartTimer() + for i := 0; i < b.N; i++ { + IndexHandler(response, request) + } +} |
