Skip to content

Commit

Permalink
updated test to handle empty response
Browse files Browse the repository at this point in the history
wiretap will tell you the response is empty.
  • Loading branch information
daveshanley committed Apr 30, 2024
1 parent acf98f8 commit 97b5abb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions mock/mock_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,12 +340,12 @@ func (rme *ResponseMockEngine) runWorkflow(request *http.Request) ([]byte, int,

if len(mock) == 0 {
return rme.buildError(
404,
"No mock generated",
fmt.Sprintf("Nothing was generated for the request '%s' with the method '%s'. Check spec response defintions",
200,
"Response is empty",
fmt.Sprintf("Nothing was generated for the request '%s' with the method '%s'. Response is empty",
request.URL.Path, request.Method),
"not_found",
), 404, err
"empty",
), 200, err
}

return mock, c, nil
Expand Down
2 changes: 1 addition & 1 deletion mock/mock_engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ components:
b, status, err := me.GenerateResponse(request)
assert.NoError(t, err)
assert.Equal(t, 200, status)
assert.Equal(t, "", string(b))
assert.Equal(t, `{"type":"https://pb33f.io/wiretap/errors#empty","title":"Response is empty (200)","status":200,"detail":"Nothing was generated for the request '/auth' with the method 'POST'. Response is empty"}`, string(b))
}

// https://github.com/pb33f/wiretap/issues/80
Expand Down

0 comments on commit 97b5abb

Please sign in to comment.