Comments (3)
I'm afraid that that's currently not possible.
Mock has SetDefinition()
method that accepts mock definition, however definition
struct is private. It actually doesn't make sense that public method accepts private structs. I see 2 solutions here:
- Simply make
definition
andnewDefinition
function public. - Create a new API to allow pre-setup mocks.
What are your thoughts @luza?
from gonkey.
I think you could initialise a mock in this way (not an elegant, though):
m := mocks.NewNop("elastic")
def := map[string]interface{}{
"elastic": map[string]interface{}{
"strategy": // ... and so on in the way you write yaml
},
}
loader := mocks.NewLoader(m)
err := loader.Load(def)
However I also like the idea to open the mock initialisation API, i.e. not just definition
and newDefinition
but also interfaces verifier
, strategy
and bunch of builders newXXX()
for standard strategies and verifiers.
from gonkey.
Thanks for the workaround @luza, I'll have a look at it.
As for a proper solution I'd suggest sth like mocks.NewGlobal("some_mocks.yml")
for an easy and similar semantic where the yaml looks sth. like this:
elasticSearch:
strategy: methodVary
methods: ...
someOtherMock:
strategy: ...
from gonkey.
Related Issues (20)
- Начиная с релиза 1.18.2 не может быть создан Allure-отчет HOT 1
- Рефакторинг модуля с фикстурами и добавление возможности использовать переменные HOT 1
- Одновременная поддержка redis и postgres HOT 3
- Сделать путь до фейлящегося теста кликабельным HOT 9
- Оборачивать каждый тест в сабтесты HOT 3
- Add comparison params into request constraits/Добавить comparison params в request constraits HOT 1
- Добавить поддержку переменных теста в фикстуры HOT 2
- Добавить возможность объявнять кастомные функции HOT 1
- Fatal when test has status "broken" HOT 1
- Возможность использования динамических переменных
- Focus test status stopped to work HOT 1
- Реализовать механизм транзакций commit/rollback для фикстур HOT 1
- Реализовать автоматическую генерацию структуры папок и файлов при инициализации gonkey
- Параметризировать assert Response headers
- Изменение подхода работы с ContentType и поддержка application/x-www-form-urlencoded
- Fatal when set status skipped or broken HOT 3
- Добавление поддержки MongoDB в фикстурах
- Как протестировать получение файла? HOT 4
- По первой части, также количество элементов может меняться и достаточно было бы проверить код ответа и тип возвращаемых данных. Еще может быть ситуация, когда достаточно не 200, а 403 или другого кода ответа без проверки body.
- При добавлении поля `status` в тестовый сценарий, возникает ошибка `panic`.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gonkey.