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:
xucong053
2022-04-29 14:19:44 +08:00
parent 2cdca18083
commit 0283dd751e
4 changed files with 26 additions and 8 deletions

View File

@@ -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
}
}