From 97b5abbfc950482b2f12a85760a912c73a5271da Mon Sep 17 00:00:00 2001 From: quobix Date: Tue, 30 Apr 2024 09:22:04 -0400 Subject: [PATCH] updated test to handle empty response wiretap will tell you the response is empty. --- mock/mock_engine.go | 10 +++++----- mock/mock_engine_test.go | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mock/mock_engine.go b/mock/mock_engine.go index b1ac6ac..e504608 100644 --- a/mock/mock_engine.go +++ b/mock/mock_engine.go @@ -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 diff --git a/mock/mock_engine_test.go b/mock/mock_engine_test.go index fc334f6..eca1809 100644 --- a/mock/mock_engine_test.go +++ b/mock/mock_engine_test.go @@ -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