fix: error coverage

This commit is contained in:
mayur.popli
2025-03-25 03:10:35 +05:30
parent ec4b689fdc
commit 543f100dfe
2 changed files with 19 additions and 0 deletions

View File

@@ -17,6 +17,18 @@ const (
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) {
resp := &model.Response{
Message: model.Message{

View File

@@ -165,3 +165,10 @@ func compareJSON(expected, actual map[string]interface{}) bool {
actualBytes, _ := json.Marshal(actual)
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
}