Skip to content

Commit

Permalink
Refactor Request.Expect
Browse files Browse the repository at this point in the history
  • Loading branch information
gavv committed Jan 27, 2023
1 parent 4ecccaf commit 4a67412
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions request.go
Expand Up @@ -1829,27 +1829,31 @@ func (r *Request) Expect() *Response {
opChain := r.chain.enter("Expect()")
defer opChain.leave()

if opChain.failed() {
return newResponse(responseOpts{
resp := r.expect(opChain)

if resp == nil {
resp = newResponse(responseOpts{
config: r.config,
chain: opChain,
})
}

if !r.checkOrder(opChain, "Expect") {
return newResponse(responseOpts{
config: r.config,
chain: opChain,
})
return resp
}

func (r *Request) expect(opChain *chain) *Response {
if opChain.failed() {
return nil
}

if !r.checkOrder(opChain, "Expect()") {
return nil
}

resp := r.roundTrip(opChain)

if resp == nil {
return newResponse(responseOpts{
config: r.config,
chain: opChain,
})
return nil
}

for _, matcher := range r.matchers {
Expand Down

0 comments on commit 4a67412

Please sign in to comment.