fix: resolved comments
This commit is contained in:
@@ -12,14 +12,6 @@ import (
|
|||||||
"github.com/beckn/beckn-onix/pkg/model"
|
"github.com/beckn/beckn-onix/pkg/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ErrorType string
|
|
||||||
|
|
||||||
type errorResponseWriter struct{}
|
|
||||||
|
|
||||||
|
|
||||||
func (e *errorResponseWriter) Write([]byte) (int, error) {
|
|
||||||
return 0, errors.New("write error")
|
|
||||||
}
|
|
||||||
|
|
||||||
type Error struct {
|
type Error struct {
|
||||||
Code string `json:"code,omitempty"`
|
Code string `json:"code,omitempty"`
|
||||||
@@ -27,7 +19,6 @@ type Error struct {
|
|||||||
Paths string `json:"paths,omitempty"`
|
Paths string `json:"paths,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *errorResponseWriter) WriteHeader(statusCode int) {}
|
|
||||||
|
|
||||||
// SchemaValidationErr represents a collection of schema validation failures.
|
// SchemaValidationErr represents a collection of schema validation failures.
|
||||||
type SchemaValidationErr struct {
|
type SchemaValidationErr struct {
|
||||||
|
|||||||
@@ -12,6 +12,14 @@ import (
|
|||||||
"github.com/beckn/beckn-onix/pkg/model"
|
"github.com/beckn/beckn-onix/pkg/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type errorResponseWriter struct{}
|
||||||
|
|
||||||
|
// TODO: Optimize the cases by removing these
|
||||||
|
func (e *errorResponseWriter) Write([]byte) (int, error) {
|
||||||
|
return 0, errors.New("write error")
|
||||||
|
}
|
||||||
|
func (e *errorResponseWriter) WriteHeader(statusCode int) {}
|
||||||
|
|
||||||
func (e *errorResponseWriter) Header() http.Header {
|
func (e *errorResponseWriter) Header() http.Header {
|
||||||
return http.Header{}
|
return http.Header{}
|
||||||
}
|
}
|
||||||
@@ -213,12 +221,16 @@ func TestNack_1(t *testing.T) {
|
|||||||
w = httptest.NewRecorder()
|
w = httptest.NewRecorder()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Force marshal error if needed
|
// TODO: Fix this approach , should not be used like this.
|
||||||
if tt.useBadJSON {
|
if tt.useBadJSON {
|
||||||
data, _ := json.Marshal(&badMessage{})
|
data, _ := json.Marshal(&badMessage{})
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
w.WriteHeader(tt.status)
|
w.WriteHeader(tt.status)
|
||||||
w.Write(data)
|
_, err := w.Write(data)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, "Failed to write response", http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user