提交 0fceac2a 编写于 作者: aaronchen2k2k's avatar aaronchen2k2k

random on use_yaml field

上级 9283004b
......@@ -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)
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册