(t *testing.T)
| 42 | } |
| 43 | |
| 44 | func TestIndexHandler(t *testing.T) { |
| 45 | req, err := http.NewRequest("GET", "/", nil) |
| 46 | if err != nil { |
| 47 | t.Fatal(err) |
| 48 | } |
| 49 | |
| 50 | rr := httptest.NewRecorder() |
| 51 | handler := http.HandlerFunc(indexHandler) |
| 52 | |
| 53 | handler.ServeHTTP(rr, req) |
| 54 | |
| 55 | if status := rr.Code; status != http.StatusOK { |
| 56 | t.Errorf("handler returned wrong status code: got %v want %v", |
| 57 | status, http.StatusOK) |
| 58 | } |
| 59 | } |