1

I have an issue with the variable usage. Tried different options(storing variable differently, declaring, using text for defining the query, storing the query as a variable). Still have the below error:

"errors": [
        {
            "message": "invalid input syntax for type uuid: \"#(queueID)\"",
            "locations": [
                {
                    "line": 1,
                    "column": 11
                }
            ],
            "path": [
                "deleteQueue"
            ],
            "extensions": {
                "code": "INTERNAL_SERVER_ERROR",
                "exception": {
                    "name": "SequelizeDatabaseError",
                    "parent": {
                        "length": 109,
                        "name": "error",
                        "severity": "ERROR",
                        "code": "22P02",
                        "position": "34",
                        "file": "uuid.c",
                        "line": "137",
                        "routine": "string_to_uuid",
                        "sql": "DELETE FROM \"Queue\" WHERE \"id\" = '#(queueID)'"

This are my Gherkin steps:

Given request { query: 'mutation {createQueue(input: {name: "BDD-delete" }) {id} }'}
    When method POST
    Then status 200
    And match response.data.createQueue.name == "BDD-delete"
    * def queueID = response.data.createQueue.id
    * print queueID
    Given request { query: 'mutation {deleteQueue (id:"#(queueID)")} '}

And this is the output, when I print the queueID: 13:14:16.745 [main] INFO com.intuit.karate - [print] 758c0524-b18d-41f6-96aa-9db5eb8a7ac8

Tried using variable for the query

Given text payload =
      """
      mutation {
      createQueue(input: {name: "BDD-delete" }) 
      {id, name}
      }
      """

And the same tried for the deleteQueue Feels like the issue is related with str and uuid. I must pass a uuid between the brackets in "#(queueID)"

Vladislav
  • 13
  • 5

1 Answers1

0

First read this to get a sense of why this is happening: https://github.com/karatelabs/karate#rules-for-embedded-expressions

So try this:

Given request `{ query: 'mutation {deleteQueue (id:"${queueID}")} '}`

The good thing is that Karate supports JS-style placeholder replacement in strings within back-ticks.

Also refer: https://stackoverflow.com/a/69349118/143475

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248