Added two new tests for Editing Tasks.
This commit is contained in:
parent
176ba70e5c
commit
38d7058e79
|
@ -51,3 +51,35 @@ func TestAddEmptyCategory(t *testing.T) {
|
|||
t.Error("Body should be empty. Instead contained data: ", body)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEditTaskWithWrongMethod(t *testing.T) {
|
||||
ts := httptest.NewServer(http.HandlerFunc(EditTaskFunc))
|
||||
defer ts.Close()
|
||||
req, err := http.NewRequest("OPTIONS", ts.URL, nil)
|
||||
if err != nil {
|
||||
t.Errorf("Error occured while constracting request:%s", err)
|
||||
}
|
||||
w := httptest.NewRecorder()
|
||||
EditTaskFunc(w, req)
|
||||
|
||||
if w.Code != http.StatusFound && message != "Method not allowed" {
|
||||
t.Errorf("Message was: %s Return code was: %d. Should have been message: %s return code: %d", message, w.Code, "Method not allowed", http.StatusFound)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEditTaskWrongTaskName(t *testing.T) {
|
||||
ts := httptest.NewServer(http.HandlerFunc(EditTaskFunc))
|
||||
defer ts.Close()
|
||||
ts.URL = ts.URL + "/edit/invalidID"
|
||||
req, err := http.NewRequest("GET", ts.URL, nil)
|
||||
if err != nil {
|
||||
t.Errorf("Error occured while constracting request:%s", err)
|
||||
}
|
||||
w := httptest.NewRecorder()
|
||||
EditTaskFunc(w, req)
|
||||
//TODO: Error should be returned as part of the string so that the message can tell
|
||||
//why there was a problem.
|
||||
if w.Code != http.StatusBadRequest {
|
||||
t.Errorf("Actual status: (%d); Expected status:(%d)", w.Code, http.StatusBadRequest)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue