ovh/venom

How to avoid interpolating env variables?

thejan2009 opened this issue · 1 comments

One of our tests verifies the version reported by API. This this is a short sha, which can sometimes be interpreted as a number of some sort, leading to the following issues:

---
name: showcase

testcases:
- name: Version
  steps:
  - type: exec
    script: >
      echo '{"revision": "915785e5"}'
    assertions:
      - result.systemoutjson.revision ShouldEqual "{{.GIT_COMMIT}}"

Run with

~ $ VENOM_VAR_GIT_COMMIT="915785e5" venom run fail.yml
          [trac] writing venom.1.log
 • showcase (fail.yml)
        • Version FAIL
Testcase "Version", step #0-0: Assertion "result.systemoutjson.revision ShouldEqual \"91578500000\"" failed. expected: 91578500000  got: 915785e5 (fail.yml:0)
final status: FAIL

The relevant debug log line is this:

May 22 07:36:37.862 [DEBU] Adding variable from vars arg GIT_COMMIT=%!s(float64=9.15785e+10)

Is there a way to force venom to interpret this variable as a string?

Based on phind suggestion we can prepend the variable with a character that's not hex, for example
VENOM_VAR_GIT_COMMIT="x915785e5" venom run fail.yml and then remove it from assertion: result.systemoutjson.revision ShouldEqual {{ .GIT_COMMIT | replace "x" "" }}