Skip to content

key-value assertion example for JSON/YAML files is unclear #346

Description

@TCLamnidis

https://www.nf-test.com/docs/assertions/files/#json-files

The example provided in these sections of the page for assessing individual keys could be a bit clearer imo.

assert path(process.out.out_ch.get(0)).json.key == "value"

It should be made a bit clearer that this command tests that a key named key has a value of "value", and NOT that the list of keys in the JSON has only one element that is "value".
From the original example I was expecting path(process.out.out_ch.get(0)).json.key to return something like [ "metadata", "metrics" ] for my JSON that looked like { "metadata" : [...], "metrics" : [...] }.
i.e. the current phrasing made it look to me like .key is like python's .keys().

Maybe the examples could be updated to something a bit more explicit like:

assert path(process.out.out_ch.get(0)).json.tool == "nf-test"

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions