fix: unittest

This commit is contained in:
debugtalk
2022-05-05 16:03:30 +08:00
parent 8d425aa696
commit 47557a403b
3 changed files with 39 additions and 40 deletions

View File

@@ -315,7 +315,7 @@ func runStepRequest(r *SessionRunner, step *TStep) (stepResult *StepResult, err
// stat HTTP request
var httpStat httpstat.Stat
if r.HTTPStatOn() {
ctx := httpstat.WithHTTPStat(rb.req.Context(), &httpStat)
ctx := httpstat.WithHTTPStat(rb.req, &httpStat)
rb.req = rb.req.WithContext(ctx)
}
@@ -347,12 +347,6 @@ func runStepRequest(r *SessionRunner, step *TStep) (stepResult *StepResult, err
}
}
if r.HTTPStatOn() {
httpStat.Finish()
stepResult.HttpStat = httpStat.Durations()
httpStat.Print()
}
// new response object
respObj, err := newHttpResponseObject(r.hrpRunner.t, parser, resp)
if err != nil {
@@ -360,6 +354,13 @@ func runStepRequest(r *SessionRunner, step *TStep) (stepResult *StepResult, err
return
}
if r.HTTPStatOn() {
// resp.Body has been ReadAll
httpStat.Finish()
stepResult.HttpStat = httpStat.Durations()
httpStat.Print()
}
// add response object to step variables, could be used in teardown hooks
stepVariables["hrp_step_response"] = respObj.respObjMeta