ovh / venom

🐍 Manage and run your integration tests with efficiency - Venom run executors (script, HTTP Request, web, imap, etc... ) and assertions
Apache License 2.0
1.06k stars 144 forks source link

[bug] `__type__` seems to not be available anymore #785

Closed theobouge-ovh closed 7 months ago

theobouge-ovh commented 7 months ago

Hello 👋 ,

I think the __type__ value isn't available anymore at least for json object

Here is a test case forked from ShouldJSONContain.yml

name: Assertions testsuite
testcases:
  - name: test assertion ShouldJSONContain
    steps:
      - script: |
          echo '[
            {
              "a" : 1,
              "b" : 2,
              "c" : {
                "x":1,
                "y":2
              }
            },
            {
              "bar": "baz"
            }
          ]'
        assertions:
          - result.systemoutjson ShouldJSONContain ' { "c":{ "y" :2 , "x" :1 }, "b" :2 , "a" :1 } '
          - result.systemoutjson ShouldJSONContain ' { "bar":"baz" } '
          - result.systemoutjson.__type__ ShouldEqual Map

here will be the error message

$ $HOME/go/1.22.1/bin/venom-v1.2.0 version
Version venom: v1.2.0
$ $HOME/go/1.22.1/bin/venom-v1.2.0 run ./test.yaml
      [trac] writing venom.0.log
 • Assertions testsuite (./test.yaml)
    • test-assertion-ShouldJSONContain FAIL
        • exec
          Testcase "test assertion ShouldJSONContain", step #0-0: Assertion "result.systemoutjson.__type__ ShouldEqual Map" failed. expected: Map  got: <nil> (test.yaml:22)
final status: FAIL

here is the same test with venom 1.1.0

$ $HOME/go/1.22.1/bin/venom-v1.1.0 version
Version venom: v1.1.0
$ $HOME/go/1.22.1/bin/venom-v1.1.0 run ./test.yaml
      [trac] writing venom.2.log
 • Assertions testsuite (./test.yaml)
    • test-assertion-ShouldJSONContain FAIL
[ShouldJSONContain not supported ]
Testcase "test assertion ShouldJSONContain", step #0-0: Assertion "result.systemoutjson.__type__ ShouldEqual Map" failed. expected: Map  got: Array (test.yaml:22) #<--- still broken because i don't know how to use my eyes but at least not nil
final status: FAIL

Thank you

floatovh commented 7 months ago

Hello,

Faced the same "issue".

From version 1.2.0 the default VENOM_PRESERVE_CASE is set to ON, as explained here: https://github.com/ovh/venom/pull/570

You should either update the code and uppercase the first letter: "Type" and also "Len". For example: https://github.com/ovh/venom/blob/2291dfba0e83c846bd053ccbf7bc12564bd7faa1/tests/http.yml#L65

Or set the environment variable VENOM_PRESERVE_CASE to OFF.

theobouge-ovh commented 7 months ago

thanks