Skip to content

how to use variables extracted from exec result on info ? #860

@peczenyj

Description

@peczenyj

I am trying to do this:

name: Title of TestSuite
testcases:
- name: explicitCommand
  steps:
  - type: exec
    stdin: "{\"foo\":\"bar\"}"
    command: ["/usr/bin/jq", ".foo"]
    assertions:
    - result.code ShouldEqual 0
    vars:
      foo:
        from: result.systemout
    info: 
     - "foo: {{ .foo }}"
     - "output: {{ .result.systemout }}"

I was expecting print the value of variable "foo" using info

$ ./cmd/venom/dist/venom.linux-amd64 run -v test.yaml 
	  [trac] writing venom.5.log
 • Title of TestSuite (test.yaml)
 	• explicitCommand
 		• exec PASS
 		  [info] foo: {{ .foo }}
 		  [info] output: "bar"
final status: PASS

and if I understand well, the variable "foo" does not exists yet when I am executing the info, based on the logs below, is it the case?

what is the execution order of a testcase? what is the purpose behind info?

I start to think that the variable is only set if the test finish with success (and this makes sense), on this case I can only print the variables in a second step, right?

Just to confirm

$ cat venom.5.log
Jun  4 17:53:04.888 [INFO] Reading test.yaml
Jun  4 17:53:04.888 [INFO] Has 0 Secrets
Jun  4 17:53:04.888 [WARN] no user executor yml file selected
Jun  4 17:53:04.888 [INFO] Parsing testsuite test.yaml
Jun  4 17:53:04.893 [INFO] [Title of TestSuite] Starting testsuite
Jun  4 17:53:04.893 [INFO] [Title of TestSuite] With secrets in testsuite
Jun  4 17:53:04.893 [INFO] [Title of TestSuite] [explicitCommand] Starting testcase
Jun  4 17:53:04.894 [INFO] [Title of TestSuite] [explicitCommand] Step #1 content is: {"assertions":["result.code ShouldEqual 0"],"command":["/usr/bin/jq",".foo"],"info":["foo: {{ .foo }}","output: {{ .result.systemout }}"],"stdin":"{\"foo\":\"bar\"}","type":"exec","vars":{"foo":{"from":"result.systemout"}}}
Jun  4 17:53:04.897 [INFO] [Title of TestSuite] [explicitCommand] [exec] foo: {{ .foo }}%!(EXTRA <nil>)
Jun  4 17:53:04.897 [INFO] [Title of TestSuite] [explicitCommand] [exec] output: "bar"%!(EXTRA <nil>)
Jun  4 17:53:04.897 [INFO] [Title of TestSuite] [explicitCommand] Step "exec" result is "PASS"
Jun  4 17:53:04.897 [INFO] [Title of TestSuite] [explicitCommand] Assign 'foo' value '"bar"'
Jun  4 17:53:04.897 [INFO] [Title of TestSuite] [explicitCommand] Ending testcase
Jun  4 17:53:04.897 [INFO] [Title of TestSuite] Ending testsuite

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions