diff --git a/process_files.go b/process_files.go index b95b9cb0..de9fbc85 100644 --- a/process_files.go +++ b/process_files.go @@ -76,7 +76,12 @@ func (v *Venom) readFiles(ctx context.Context, filesPath []string) (err error) { // we take default vars from the testsuite, only if it's not already is global vars for k, value := range varsFromPartial { if _, ok := varCloned[k]; !ok || (varCloned[k] == "{}" && varCloned["__Len__"] == "0") { - varCloned[k] = value + // we interpolate the value of vars here, to do it only once per ts + valueInterpolated, err := interpolate.Do(value, varsFromPartial) + if err != nil { + return errors.Wrapf(err, "unable to parse variable %q", k) + } + varCloned[k] = valueInterpolated } } diff --git a/tests/random_vars.yml b/tests/random_vars.yml new file mode 100644 index 00000000..97e68da2 --- /dev/null +++ b/tests/random_vars.yml @@ -0,0 +1,20 @@ +name: testsuite +vars: + phone_number: "+3375{{ randNumeric 7 }}" +testcases: +- name: test 1 + steps: + - type: exec + script: echo '{{.phone_number}}' + info: '{{.phone_number}} test 1' + vars: + myvariable: + from: result.systemout + regex: ([a-z0-9\+]+) +- name: test 2 + steps: + - type: exec + script: echo '{{.phone_number}}' + info: '{{.phone_number}} test 2' + assertions: + - result.systemout ShouldEqual {{.test-1.myvariable}}