mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-12 16:01:27 +08:00
fix: unsafe to write concurrent map and failed to parse parameters(type:[][]interface{}) in testcase script while data driven for testing
This commit is contained in:
@@ -52,12 +52,12 @@ func (r *SessionRunner) Start(givenVars map[string]interface{}) error {
|
||||
config := r.testCase.Config
|
||||
log.Info().Str("testcase", config.Name).Msg("run testcase start")
|
||||
|
||||
// update config variables with given variables
|
||||
r.updateConfigVariables(givenVars)
|
||||
|
||||
// reset session runner
|
||||
r.resetSession()
|
||||
|
||||
// update config variables with given variables
|
||||
r.updateSessionVariables(givenVars)
|
||||
|
||||
// run step in sequential order
|
||||
for _, step := range r.testCase.TestSteps {
|
||||
log.Info().Str("step", step.Name()).
|
||||
@@ -122,16 +122,16 @@ func (r *SessionRunner) MergeStepVariables(vars map[string]interface{}) (map[str
|
||||
return parsedVariables, nil
|
||||
}
|
||||
|
||||
// updateConfigVariables updates config variables with given variables.
|
||||
// updateSessionVariables updates session variables with given variables.
|
||||
// this is used for data driven
|
||||
func (r *SessionRunner) updateConfigVariables(parameters map[string]interface{}) {
|
||||
func (r *SessionRunner) updateSessionVariables(parameters map[string]interface{}) {
|
||||
if len(parameters) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
log.Info().Interface("parameters", parameters).Msg("update config variables")
|
||||
log.Info().Interface("parameters", parameters).Msg("update session variables")
|
||||
for k, v := range parameters {
|
||||
r.parsedConfig.Variables[k] = v
|
||||
r.sessionVariables[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user