add tests for notification server errors (#30)

This commit is contained in:
Kirill
2023-07-29 02:59:03 +03:00
committed by GitHub
parent 6c1a5e35c0
commit 651c39595f
2 changed files with 139 additions and 10 deletions

View File

@@ -53,12 +53,7 @@ func (ns *NotificationServer) handler(rw http.ResponseWriter, httpReq *http.Requ
Name: "Ozon Seller API",
Time: time.Now(),
}
respJson, err := json.Marshal(resp)
if err != nil {
log.Print(err)
ns.error(rw, http.StatusInternalServerError, err)
return
}
respJson, _ := json.Marshal(resp)
rw.WriteHeader(http.StatusOK)
rw.Write(respJson)
@@ -68,8 +63,7 @@ func (ns *NotificationServer) handler(rw http.ResponseWriter, httpReq *http.Requ
req, err := ns.unmarshal(mt.MessageType, content)
if err != nil {
log.Print(err)
ns.result(rw, false)
//ns.error(rw, http.StatusInternalServerError, err)
ns.error(rw, http.StatusInternalServerError, err)
return
}
h, ok := ns.handlers[mt.MessageType]
@@ -80,8 +74,7 @@ func (ns *NotificationServer) handler(rw http.ResponseWriter, httpReq *http.Requ
}
if err := h(req); err != nil {
log.Print(err)
ns.result(rw, false)
//ns.error(rw, http.StatusInternalServerError, err)
ns.result(rw, true)
return
}