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

mocks file reply strategy: show error when no file found by filepath #96

Merged
merged 1 commit into from
Sep 4, 2021

Conversation

NikolayOskin
Copy link
Contributor

@NikolayOskin NikolayOskin commented Sep 4, 2021

Приведу пример теста:

- name: test name
  method: POST
  path: /some/path
  mocks:
    eventBus:
      calls: 1
      strategy: uriVary
      uris:
        /jsonrpc/v2/events.produce:
          calls: 1
          strategy: file

          # файла не существует по указанному пути
          filename: mocks/event-bus-success.json

Когда мок файла не существует по указанному пути, замоканный сервис при обращении к нему вернет клиентам пустое тело ответа с заголовком Content-Length: 0, что может привести к неожиданному поведению.
При написании тестов можно допустить трудноуловимые опечатки в путях (нижнее подчеркивание вместо дефисов в имени файла, например). И фреймворк в текущей версии не подскажет о том, что мок-файла не существует.

С этой правкой, при запуске тестов в логе будет указано:
runner_testing.go:99: unable to load definition for eventBus: open mocks/event-bus-success.json: no such file or directory.

Запускаемый тест зафейлится, давая тестировщику понять причину фейла.

@fetinin fetinin added bug Something isn't working patch release as patch labels Sep 4, 2021
@fetinin
Copy link
Contributor

fetinin commented Sep 4, 2021

👍

@fetinin fetinin merged commit 32d7bd8 into lamoda:master Sep 4, 2021
@github-actions
Copy link

github-actions bot commented Sep 4, 2021

🚀 PR was released in v1.4.2 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working patch release as patch released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants