diff options
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) + } +} |
