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

Venom failed to decode string in assertion #139

Closed
neyaled opened this issue Feb 22, 2018 · 3 comments
Closed

Venom failed to decode string in assertion #139

neyaled opened this issue Feb 22, 2018 · 3 comments

Comments

@neyaled
Copy link

neyaled commented Feb 22, 2018

We have a test where we would like to check that a message is correctly set.

The assertion is the following:

assertions:

  • result.bodyjson.message ShouldContain 'Missing parameter: name'

The assertion fails with:

  • 'Assertions[2]' expected type 'string', got unconvertible type 'map[interface {}]interface {}'
    --

Single quotes or Double quotes produce the same result. Escaping the ':' as well.

@strokyl
Copy link

strokyl commented Feb 23, 2018

The problem is that yaml processing is analyzing 'Missing parameter: name' as a mapping!
I had the same issue the solution is to use:

'result.bodyjson.message ShouldContain "Missing parameter: name"'

instead of:

result.bodyjson.message ShouldContain 'Missing parameter: name'

@matcornic
Copy link
Contributor

matcornic commented Dec 17, 2019

I had the same issue. Here is a highlighted version of the explanation.

Doesn't work:

    - type: http
      method: POST
      url: "my/url"
      assertions:
        - result.statuscode ShouldEqual 400
        - result.bodyjson.message ShouldEqual "Missing parameter: name"

Works:

    - type: http
      method: POST
      url: "my/url"
      assertions:
        - result.statuscode ShouldEqual 400
        - 'result.bodyjson.message ShouldEqual "Missing parameter: name"'

Just wrap the whole assertion with quotes and it's good 👍

@yesnault
Copy link
Member

yesnault commented Jan 4, 2020

cf. @matcornic response.

@yesnault yesnault closed this as completed Jan 4, 2020
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

No branches or pull requests

4 participants