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

Two interactions that only differ by query string #12

Closed
tshortt opened this issue Sep 20, 2016 · 8 comments
Closed

Two interactions that only differ by query string #12

tshortt opened this issue Sep 20, 2016 · 8 comments

Comments

@tshortt
Copy link

tshortt commented Sep 20, 2016

Is it possible to add two different interactions that only differ by query string. Here's an example of what I'm trying to accomplish:

projectsProvider.addInteraction({ uponReceiving: 'a request for employee', withRequest: { method: 'get', path: '/EmployeeApi/api/organizations/0/employees' }

versus

projectsProvider.addInteraction({ uponReceiving: 'a request for employee with emails', withRequest: { method: 'get', path: '/EmployeeApi/api/organizations/0/employees', query: { 'include': 'emails' } }

Error:
Failed: Actual interactions do not match expected interactions for mock MockService.

Missing requests:
GET /EmployeeApi/api/organizations/0/employees?include=emails

@mefellows
Copy link
Member

Hi @tshortt, yes that should be possible - uniqueness for a request is calculated as a combination of the attributes in the withRequest block.

Could you please provide a Gist to some code? It's more than likely a setup problem.

@tarciosaraiva
Copy link
Contributor

Following up on @mefellows answer above, @tshortt could you please also provide the log generated by your test? When the mock server runs it creates a log under <project>/logs/mockserver-integration.log that would contain the interactions setup / received.

@tarciosaraiva
Copy link
Contributor

@tshortt I just realised I didn't have any test related to this case so I'm adding one now. Here's the output I got from my mock server log:

I, [2016-09-21T09:03:53.219929 #14094]  INFO -- : Registered expected interaction GET /projects?from=today
D, [2016-09-21T09:03:53.221251 #14094] DEBUG -- : {
  "description": "a request for projects",
  "provider_state": "i have a list of projects",
  "request": {
    "method": "GET",
    "path": "/projects",
    "query": {
      "from": [
        "today"
      ]
    },
    "headers": {
      "Accept": "application/json"
    }
  },
  "response": {
    "status": 200,
    "headers": {
      "Content-Type": "application/json"
    },
    "body": [
      {
        "id": 1,
        "name": "Project 1",
        "due": "2016-02-11T09:46:56.023Z",
        "tasks": [
          {
            "id": 1,
            "name": "Do the laundry",
            "done": true
          },
          {
            "id": 2,
            "name": "Do the dishes",
            "done": false
          },
          {
            "id": 3,
            "name": "Do the backyard",
            "done": false
          },
          {
            "id": 4,
            "name": "Do nothing",
            "done": false
          }
        ]
      }
    ]
  }
}
I, [2016-09-21T09:03:53.234556 #14094]  INFO -- : Received request GET /projects?from=today
D, [2016-09-21T09:03:53.235412 #14094] DEBUG -- : {
  "path": "/projects",
  "query": "from=today",
  "method": "get",
  "headers": {
    "Host": "localhost:9744",
    "Accept-Encoding": "gzip, deflate",
    "User-Agent": "node-superagent/2.2.0",
    "Accept": "application/json",
    "Connection": "close",
    "Https": "on",
    "Version": "HTTP/1.1"
  }
}
I, [2016-09-21T09:03:53.236346 #14094]  INFO -- : Found matching response for GET /projects?from=today
D, [2016-09-21T09:03:53.237597 #14094] DEBUG -- : {
  "status": 200,
  "headers": {
    "Content-Type": "application/json"
  },
  "body": [
    {
      "id": 1,
      "name": "Project 1",
      "due": "2016-02-11T09:46:56.023Z",
      "tasks": [
        {
          "id": 1,
          "name": "Do the laundry",
          "done": true
        },
        {
          "id": 2,
          "name": "Do the dishes",
          "done": false
        },
        {
          "id": 3,
          "name": "Do the backyard",
          "done": false
        },
        {
          "id": 4,
          "name": "Do nothing",
          "done": false
        }
      ]
    }
  ]
}
I, [2016-09-21T09:03:53.245853 #14094]  INFO -- : Verifying - interactions matched for example ""
I, [2016-09-21T09:03:53.255236 #14094]  INFO -- : Writing pact with details {:consumer=>{:name=>"Consumer 1"}, :provider=>{:name=>"Provider 1"}}
I, [2016-09-21T09:03:53.255425 #14094]  INFO -- : Writing pact for Provider 1 to /home/nab/workspace/pact-js/pacts/consumer_1-provider_1.json
I, [2016-09-21T09:03:53.264434 #14094]  INFO -- : Cleared interactions before example ""

Here's the test added: https://github.com/pact-foundation/pact-js/blob/master/test/dsl/integration.spec.js#L100

@tshortt
Copy link
Author

tshortt commented Sep 21, 2016

@tarciosaraiva
Copy link
Contributor

hi @tshortt looks like it might be a bug with the pact mock server. I opened a new issue there, let's see what comes back 👍

@mefellows
Copy link
Member

Marking as enhancement, waiting on pact-foundation/pact-mock_service/issues/54.

@stale
Copy link

stale bot commented Feb 10, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Feb 10, 2019
@stale stale bot closed this as completed Feb 17, 2019
@mefellows mefellows removed the wontfix label Feb 17, 2019
@mefellows
Copy link
Member

I've just tested this and your scenario should work as expected. I'm not sure where along the lines this was fixed, but it is :)

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

3 participants