fix: error coverage
This commit is contained in:
@@ -17,6 +17,18 @@ const (
|
|||||||
InvalidRequestErrorType ErrorType = "INVALID_REQUEST"
|
InvalidRequestErrorType ErrorType = "INVALID_REQUEST"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type errorResponseWriter struct{}
|
||||||
|
|
||||||
|
func (e *errorResponseWriter) Header() http.Header {
|
||||||
|
return http.Header{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *errorResponseWriter) Write([]byte) (int, error) {
|
||||||
|
return 0, errors.New("write error")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *errorResponseWriter) WriteHeader(statusCode int) {}
|
||||||
|
|
||||||
func SendAck(w http.ResponseWriter) {
|
func SendAck(w http.ResponseWriter) {
|
||||||
resp := &model.Response{
|
resp := &model.Response{
|
||||||
Message: model.Message{
|
Message: model.Message{
|
||||||
|
|||||||
@@ -165,3 +165,10 @@ func compareJSON(expected, actual map[string]interface{}) bool {
|
|||||||
actualBytes, _ := json.Marshal(actual)
|
actualBytes, _ := json.Marshal(actual)
|
||||||
return bytes.Equal(expectedBytes, actualBytes)
|
return bytes.Equal(expectedBytes, actualBytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func TestSendAck_WriteError(t *testing.T) {
|
||||||
|
w := &errorResponseWriter{}
|
||||||
|
SendAck(w)
|
||||||
|
// No need to assert, just ensure it doesn't panic
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user