Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add default value for var #549

Merged
merged 4 commits into from
Jun 15, 2022
Merged

feat: add default value for var #549

merged 4 commits into from
Jun 15, 2022

Conversation

guoweis-work
Copy link
Contributor

@guoweis-work guoweis-work commented May 10, 2022

today, if one of the json elements can't be found, none of the resolution works

name: Exec testsuite
testcases:
  - name: catjson
    steps:
      - script: cat exec/testa.json
        info: "the value of result.systemoutjson is {{.result.systemoutjson}}"
        assertions:
          - result.systemoutjson.foo ShouldContainSubstring bar
        vars:
          foo:
            from: result.systemoutjson.foo
          bar:
            from: result.systemoutjson.bar
            default: "test"
      - script: echo "{{.catjson.foo}}"
        info: "the value of foo is {{.catjson.foo}} {{.catjson.bar}}"

this is the output

 • Exec testsuite (tests/exec.yml)
 	• catjson FAILURE
	  [info] the value of result.systemoutjson is {"foo":"bar"} (tests/exec.yml:29)
	  [info] the value of foo is {{.catjson.foo}} {{.catjson.bar}} (tests/exec.yml:39)

This change allows a default value to be specified such that if it's missing from the json, the default value will be used.

Copy link
Member

@yesnault yesnault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @guoweis-outreach,
Thank you for this proposal. It's ok to include that into venom. Can you:

  • add some tests into tests/ directory
  • add some doc about this into the README

Thank you

guowei shieh added 3 commits May 11, 2022 11:50
Signed-off-by: guowei shieh <[email protected]>
Signed-off-by: guowei shieh <[email protected]>
Signed-off-by: guowei shieh <[email protected]>
@guoweis-work
Copy link
Contributor Author

@yesnault does this seem good to you?

Copy link
Member

@yesnault yesnault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @guoweis-outreach !

LGTM

@yesnault yesnault merged commit 67e4628 into ovh:master Jun 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants