Added some db unit tests

This commit is contained in:
Jamie Curnow
2023-07-26 13:29:12 +10:00
parent d555af68fe
commit e4e70ae6be
7 changed files with 198 additions and 55 deletions

View File

@ -139,7 +139,11 @@ func DeleteUser() func(http.ResponseWriter, *http.Request) {
case sql.ErrNoRows:
h.NotFound(w, r)
case nil:
h.ResultResponseJSON(w, r, http.StatusOK, item.Delete())
if err := item.Delete(); err != nil {
h.ResultErrorJSON(w, r, http.StatusBadRequest, err.Error(), nil)
} else {
h.ResultResponseJSON(w, r, http.StatusOK, true)
}
default:
h.ResultErrorJSON(w, r, http.StatusBadRequest, err.Error(), nil)
}