smocker-dev / smocker

Smocker is a simple and efficient HTTP mock server and proxy
https://smocker.dev
MIT License
1.14k stars 61 forks source link

Q: What is session and how to use it? #279

Closed adaamz closed 1 year ago

adaamz commented 1 year ago

Hey, firstly thanks for this tool, looks kinda early but I like it.

My first question is regarding sessions - what are they good for? I would like to somehow categorize mocks per service (api server), so I see requests history for each service and I see mocks for that service.

My next question/bug - Why do I see mocks from only one session if I defined 2 sessions? I have defined 2 sessions (can be api1, api2), when I click on second session I see defined mocks, but when I click on first session I see no mocks and I evne cannot add any mocks there (button is missing).

I use pretty straight-forward docker-compose.yml:

  mock-api:
    image: thiht/smocker
    environment:
      SMOCKER_PERSISTENCE_DIRECTORY: /tmp/smocker
    user: "1000"
    ports:
      - "10090:8080"
      - "10091:8081"
    volumes:
      - ./tests/smocker_sessions:/tmp/smocker

image image

gwleclerc commented 1 year ago

Hi,

Smocker was designed to be used in integration tests, whether automated or manual.

Sessions correspond to test suites and allow you to keep history between execution. They have not been designed to run in parallel and only one session can be active at a time (the last one). It corresponds to a specific test context: mocks and call history.

gwleclerc commented 1 year ago

To go a step further, I invite you to read the Real Lise Usage section of the documentation, as well as Smocker's venom test suites.

I've also made a small golang example with some slides here: https://github.com/gwleclerc/venom_smocker_example

adaamz commented 1 year ago

OK, thx. Yeah I read real life usage, but I don't understand it much and its not much verbose to me 🙁