Skip to content

Commit

Permalink
Check and return early when lowest success code is 204
Browse files Browse the repository at this point in the history
  • Loading branch information
martinsirbe authored and daveshanley committed May 13, 2024
1 parent e283619 commit effef1f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mock/mock_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,11 @@ func (rme *ResponseMockEngine) runWorkflow(request *http.Request) ([]byte, int,
mt, noMT = rme.findBestMediaTypeMatch(operation, request, []string{lo})
}

c, _ := strconv.Atoi(lo)
if c == http.StatusNoContent {
return nil, c, nil
}

if mt == nil && noMT {
mtString := rme.extractMediaTypeHeader(request)
return rme.buildError(
Expand All @@ -336,7 +341,6 @@ func (rme *ResponseMockEngine) runWorkflow(request *http.Request) ([]byte, int,
"build_mock_error",
), 422, mockErr
}
c, _ := strconv.Atoi(lo)

if len(mock) == 0 {
return rme.buildError(
Expand Down

0 comments on commit effef1f

Please sign in to comment.