Skip to content

Instantly share code, notes, and snippets.

@krishbhanushali
Created April 16, 2019 21:06
Show Gist options
  • Save krishbhanushali/69cebb5e24441f891746e8968b38fbf5 to your computer and use it in GitHub Desktop.
Save krishbhanushali/69cebb5e24441f891746e8968b38fbf5 to your computer and use it in GitHub Desktop.
func TestGetEntryByIDNotFound(t *testing.T) {
req, err := http.NewRequest("GET", "/entry", nil)
if err != nil {
t.Fatal(err)
}
q := req.URL.Query()
q.Add("id", "123")
req.URL.RawQuery = q.Encode()
rr := httptest.NewRecorder()
handler := http.HandlerFunc(GetEntryByID)
handler.ServeHTTP(rr, req)
if status := rr.Code; status == http.StatusOK {
t.Errorf("handler returned wrong status code: got %v want %v",
status, http.StatusBadRequest)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment