Created
April 16, 2019 23:39
-
-
Save krishbhanushali/061bcc665f6829148c214ad82f1cd5d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func TestDeleteEntry(t *testing.T) { | |
req, err := http.NewRequest("DELETE", "/entry", nil) | |
if err != nil { | |
t.Fatal(err) | |
} | |
q := req.URL.Query() | |
q.Add("id", "4") | |
req.URL.RawQuery = q.Encode() | |
rr := httptest.NewRecorder() | |
handler := http.HandlerFunc(DeleteEntry) | |
handler.ServeHTTP(rr, req) | |
if status := rr.Code; status != http.StatusOK { | |
t.Errorf("handler returned wrong status code: got %v want %v", | |
status, http.StatusOK) | |
} | |
expected := `{"id":4,"first_name":"xyz change","last_name":"pqr","email_address":"xyz@pqr.com","phone_number":"1234567890"}` | |
if rr.Body.String() != expected { | |
t.Errorf("handler returned unexpected body: got %v want %v", | |
rr.Body.String(), expected) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment