Skip to content
This repository has been archived by the owner on Mar 28, 2022. It is now read-only.

New format for defining fixtures and behaviors #109

Closed
javierbrea opened this issue Dec 22, 2020 · 0 comments · Fixed by #130
Closed

New format for defining fixtures and behaviors #109

javierbrea opened this issue Dec 22, 2020 · 0 comments · Fixed by #130
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@javierbrea
Copy link
Member

javierbrea commented Dec 22, 2020

Currently there is a "pain point" when defining fixtures: All fixtures responding to the same request have to redefined its url, and there is no a clear mechanism to identify how many of them correspond to a single url. You can know the total amount of fixtures you have defined (in the CLI, for example), but you can't know how many single routes are you listening to.

As a proposal, fixtures should be renamed into routes, which I consider can be clearer, and should have a variants property, which should contain all possible responses for the same url, as in:

{
  "id":"get-users",
  "url":"/api/users",
  "method":"GET",
  "variants":[
    {
      "id":"empty",
      "response":{
        "status":200,
        "body":[
          
        ]
      }
    },
    {
      "id":"error",
      "response":{
        "status":500,
        "body":{
          "message":"Internal server error"
        }
      }
    }
  ]
}

Then, behaviors (which could be renamed into mocks for more clarity), should be defined as in:

[
  {
    "id": "base",
    "routes": ["get-users:success"]
  },
  {
    "id": "users-error",
    "from": "base",
    "routes": ["get-users:error"]
  }
]

Routes and variants could also include a handler property which should decide the routesHandler to use when loading it, as in:

{
  "id":"get-users",
  "url":"/api/users",
  "method":"GET",
  "variants":[
    {
      "id":"empty",
      "response":{
        "status":200,
        "body":[]
      }
    },
    {
      "id":"real",
      "handler": "proxy",
      "redirect": "http://localhost:8080/users"
    }
  ]
}
@javierbrea javierbrea added this to the v2.0.0 milestone Dec 22, 2020
@javierbrea javierbrea added this to To do in mocks-server via automation Dec 22, 2020
@javierbrea javierbrea moved this from To do to In progress in mocks-server Jan 10, 2021
@javierbrea javierbrea self-assigned this Jan 10, 2021
@javierbrea javierbrea added the enhancement New feature or request label Jan 10, 2021
@javierbrea javierbrea moved this from In progress to Ready for release in mocks-server Jan 16, 2021
mocks-server automation moved this from Ready for release to Done Feb 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
Status: Done
mocks-server
  
Done
Development

Successfully merging a pull request may close this issue.

1 participant