From 6ccc222340ed91424566440efbc8018aa0dc2ce4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E8=81=AA?= Date: Tue, 4 Jan 2022 15:50:21 +0800 Subject: [PATCH] feat: data-driven. --- boomer.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/boomer.go b/boomer.go index 7096aee9..f547938b 100644 --- a/boomer.go +++ b/boomer.go @@ -1,9 +1,10 @@ package hrp import ( - "github.com/jinzhu/copier" "time" + "github.com/jinzhu/copier" + "github.com/rs/zerolog/log" "github.com/httprunner/hrp/internal/boomer" @@ -70,17 +71,17 @@ func (b *hrpBoomer) convertBoomerTask(testcase *TestCase) *boomer.Task { var transactionSuccess = true // flag current transaction result cfg := testcase.Config.ToStruct() - testCaseVariables := &TConfig{} + caseConfig := &TConfig{} // copy config to avoid data racing - if err := copier.Copy(testCaseVariables, cfg); err != nil { + if err := copier.Copy(caseConfig, cfg); err != nil { log.Error().Err(err).Msg("copy config data failed") } if it := cfg.ParametersSetting.Iterator; it.HasNext() { - testCaseVariables.Variables = mergeVariables(it.Next(), cfg.Variables) + caseConfig.Variables = mergeVariables(it.Next(), cfg.Variables) } startTime := time.Now() for index, step := range testcase.TestSteps { - stepData, err := runner.runStep(index, testCaseVariables) + stepData, err := runner.runStep(index, caseConfig) if err != nil { // step failed var elapsed int64