diff --git a/src/gen/generator.go b/src/gen/generator.go index 2245794b97b6dda89497da50e99fc9819a656ec2..8d7f21f19d5cf5c6f8c8913235416b922bf02463 100644 --- a/src/gen/generator.go +++ b/src/gen/generator.go @@ -41,9 +41,6 @@ func GenerateForDefinition(defaultFile, configFile string, fieldsToExport *[]str field.From = vari.Def.From } values := GenerateForField(&field, true) - if field.Rand { - rows = randomValues(rows) - } vari.Def.Fields[index].Precision = field.Precision @@ -166,6 +163,10 @@ func GenerateForField(field *model.DefField, withFix bool) (values []string) { values = GenerateFieldValuesForDef(field) } + if field.Rand { + values = randomValues(values) + } + return values } @@ -359,7 +360,16 @@ func putChildrenToArr(arrOfArr [][]string) (values [][]string) { return } -func randomValues(values [][]string) (ret [][]string) { +func randomValuesArr(values [][]string) (ret [][]string) { + length := len(values) + for i := 0; i < length; i++ { + val := commonUtils.RandNum(length) + ret = append(ret, values[val]) + } + + return +} +func randomValues(values []string) (ret []string) { length := len(values) for i := 0; i < length; i++ { val := commonUtils.RandNum(length) diff --git a/src/gen/list.go b/src/gen/list.go index 72b6732a111793c00ff5c856d40e4537ac46fbaa..f96bf5896d95add5844ae30e3b53374ac3c71036 100644 --- a/src/gen/list.go +++ b/src/gen/list.go @@ -228,12 +228,12 @@ func CreateValuesFromYaml(field *model.DefField, yamlFile, stepStr string, repea configFile := vari.ConfigDir + yamlFile fieldsToExport := make([]string, 0) // set to empty to use all fields rows, colIsNumArr, _ := GenerateForDefinition("", configFile, &fieldsToExport) - items = Print(rows, constant.FormatData, "", colIsNumArr, fieldsToExport) - if field.Rand { - rows = randomValues(rows) + rows = randomValuesArr(rows) } + items = Print(rows, constant.FormatData, "", colIsNumArr, fieldsToExport) + if repeat > 0 { if repeat > len(items) - 1 { repeat = len(items) - 1