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

Use methods in response expectations #27

Open
schcsaba opened this issue Apr 15, 2024 · 1 comment
Open

Use methods in response expectations #27

schcsaba opened this issue Apr 15, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@schcsaba
Copy link

In certain cases, for example, if we want to verify an id or a date generated by a fixture, it would be useful to have the possibility of using methods in the response expectations the same way as in the request uri parameters or in the request body.

In this request, defined in a yaml file, I would like to expect an id in the response, but it's not possible at present:

requests:
  Success (200):
    uri:
      base: /api/institutions/agreement-templates/{agreementTemplate}
      parameters:
        '{agreementTemplate}': '<agreementTemplateUid("Agreement Template Ronald Reagan UCLA Medical Center", ["HU"])>'
    method: PUT
    headers:
      <<: *headers
    body:
      uid: '<agreementTemplateUid("Agreement Template Ronald Reagan UCLA Medical Center", ["HU"])>'
      name: MyAgreementTemplate
      file: '<mediaIdFromName("file-not-taken.pdf")>'
      filename: file-not-taken.pdf
      geographicalRestrictions:
        - FR
        - US
    statusCode: 200
    valuesNeedsToMatch:
 # This is not possible -> "[data][attributes][uid]":  '<agreementTemplateUid("Agreement Template Ronald Reagan UCLA Medical Center", ["HU"])>'
      "[data][attributes][name]": MyAgreementTemplate
      "[data][attributes][filename]": file-not-taken.pdf
      "[data][attributes][geographicalRestrictions]":
        - FR
        - US
      "[data][relationships][media][data][attributes][name]": file-not-taken.pdf

I was not able to come up with an alternative solution. I use static values in the fixtures or I just leave out dynamic values from the response expectations.

@schcsaba schcsaba added the enhancement New feature or request label Apr 15, 2024
@shulard
Copy link
Member

shulard commented Dec 10, 2024

Sorry for the delay 😞.

I think that's interesting, what about defining variable in the YAML then using those variable inside the response and the query. This way we'll have the ability to use those information everywhere we want.

What I've in mind is adding a root level variables entry, that will be interpreted then injected in all the relevant selection during the test execution.

WDYT ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants