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

New: regexp in query matching #132

Merged
merged 2 commits into from
May 12, 2022
Merged

Conversation

ikramanop
Copy link

Добавлен новый тип requestConstraints для моков - queryMatchesRegexp

Для сравнения по regexp написана функция для сравнения значений query параметров, используемая только в queryMatchesRegexp

Для новых фич написаны тесты, дополнена документация

@ikramanop ikramanop changed the title Regexp in query matching New: regexp in query matching Mar 17, 2022
README-ru.md Outdated
@@ -772,6 +772,25 @@ runner.RunWithTesting(t, &runner.RunWithTestingParams{
...
```

###### queryMatchesRegexp

Расширяет `queryMatches` так, чтобы можно было испозовать проверку по регулярному выражению.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

опечатка "использовать"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Поправил

Расширяет `queryMatches` так, чтобы можно было испозовать проверку по регулярному выражению.

Параметры:
- `expectedQuery` (обязательный) - строка параметров с которой будет сверяться запрос. Порядок параметров не имеет значения.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а есть какая-то причина почему эту функциональность нельзя сделать в queryMatches? Не думаю что кто-то использовал $matchRegexp в своих тестах

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а есть какая-то причина почему эту функциональность нельзя сделать в queryMatches? Не думаю что кто-то использовал $matchRegexp в своих тестах

Вынес в отдельный contraint для того, чтобы не было шанса сломать существующие тесты из-за использования новой функции Compare

Copy link
Contributor

@keyclaim keyclaim Mar 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тесты не должны сломаться, так как это лишь внутренняя реализация verify.
Старый verify просто делает deepEq после сортировки(regExp там не было).
Так что будет только расширение функционала.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ну вот надо бы как-нибудь убедиться в том, что точно ничего не сломается. Возможно, стоит подумать над дополнительными тестами здесь, посмотреть какие проверки делаются в реальных проектах. Есть стойкое ощущение, что мог что-то не учесть

@Cdayz Cdayz added enhancement New feature or request minor release as minor labels May 11, 2022
@Cdayz Cdayz merged commit 6ccbe91 into lamoda:master May 12, 2022
@github-actions
Copy link

🚀 PR was released in v1.15.0 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request minor release as minor released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants