You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`-spec <...>` путь к файлу или URL со swagger-спецификацией сервиса
61
62
-`-host <...>` хост:порт сервиса
62
63
-`-tests <...>` файл или директория с тестами
63
-
-`-db-type <...>` - тип базы данных. В данный момент поддерживается PostgreSQL, Aerospike, Redis.
64
+
-`-db-type <...>` - тип базы данных. В данный момент поддерживается PostgreSQL, Aerospike, Redis, MongoDB.
64
65
-`-db_dsn <...>` dsn для вашей тестовой SQL базы данных (бд будет очищена перед наполнением!), поддерживается только PostgreSQL
65
66
-`-aerospike_host <...>` при использовании Aerospike - URL для подключения к нему в формате `host:port/namespace`
66
67
-`-redis_url <...>` при использовании Redis - адрес для подключения к Redis, например `redis://user:password@localhost:6789/1?dial_timeout=1&db=1&read_timeout=6s&max_retries=2`
68
+
-`-mongo_dsn <...>` при использовании MongoDB - URL для подключения в формате `mongodb://user:password@host:port`
67
69
-`-fixtures <...>` директория с вашими фикстурами
68
70
-`-allure` генерировать allure-отчет
69
71
-`-v` подробный вывод
@@ -876,6 +878,50 @@ databases:
876
878
value: value4
877
879
```
878
880
881
+
### MongoDB
882
+
883
+
Для того, чтобы подключить MongoDB необходимо:
884
+
- Для CLI-версии: использовать флаги `-db-type mongo` и `mongo_dsn { connectionString }`;
885
+
- Для Package-версии: при конфигурации раннера установить `DbType: fixtures.Mongo` и пробросить mongo клиент `Mongo: {mongo client}`.
886
+
887
+
Формат файлов с фикстурами для Mongo:
888
+
```yaml
889
+
collections:
890
+
collection1:
891
+
- field1: "value1"
892
+
field2: 1
893
+
- field1: "value2"
894
+
field2: 2
895
+
field3: 2.569947773654566
896
+
collection2:
897
+
- field4: false
898
+
field5: null
899
+
field1: '"'
900
+
- field1: "'"
901
+
field5:
902
+
- 1
903
+
- '2'
904
+
```
905
+
906
+
Если используются разные базы данных:
907
+
908
+
```yaml
909
+
collections:
910
+
database1.collection1:
911
+
- f1: value1
912
+
f2: value2
913
+
914
+
database2.collection2:
915
+
- f1: value3
916
+
f2: value4
917
+
918
+
collection3:
919
+
- f1: value5
920
+
f2: value6
921
+
```
922
+
923
+
Оператор `eval` не поддерживается.
924
+
879
925
## Моки
880
926
881
927
Чтобы для тестов имитировать ответы от внешних сервисов, применяются моки.
Copy file name to clipboardExpand all lines: README.md
+47-2Lines changed: 47 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ Capabilities:
8
8
9
9
- works with REST/JSON API
10
10
- tests service API for compliance with OpenAPI-specs
11
-
- seeds the DB with fixtures data (supports PostgreSQL, MySQL, Aerospike, Redis)
11
+
- seeds the DB with fixtures data (supports PostgreSQL, MySQL, Aerospike, Redis, MongoDB)
12
12
- provides mocks for external services
13
13
- can be used as a library and ran together with unit-tests
14
14
- stores the results as an [Allure](http://allure.qatools.ru/) report
@@ -37,6 +37,7 @@ Capabilities:
37
37
-[Expressions](#expressions)
38
38
-[Aerospike](#aerospike)
39
39
-[Redis](#redis)
40
+
-[MongoDB](#mongodb)
40
41
-[Mocks](#mocks)
41
42
-[Running mocks while using gonkey as a library](#running-mocks-while-using-gonkey-as-a-library)
42
43
-[Mocks definition in the test file](#mocks-definition-in-the-test-file)
@@ -62,8 +63,9 @@ To test a service located on a remote host, use gonkey as a console util.
62
63
-`-spec <...>` path to a file or URL with the swagger-specs for the service
63
64
-`-host <...>` service host:port
64
65
-`-tests <...>` test file or directory
65
-
-`-db-type <...>` - database type. PostgreSQL, Aerospike, Redis are currently supported.
66
+
-`-db-type <...>` - database type. PostgreSQL, Aerospike, Redis, Mongo are currently supported.
66
67
-`-aerospike_host <...>` when using Aerospike - connection URL in a form of `host:port/namespace`
68
+
-`-mongo_dsn <...>` when using MongoDB - connection URL in a form of `mongodb://user:password@host:port`
67
69
-`-redis_url <...>` when using Redis - connection address, for example `redis://user:password@localhost:6789/1?dial_timeout=1&db=1&read_timeout=6s&max_retries=2`
68
70
-`-db_dsn <...>` DSN for the test DB (the DB will be cleared before seeding!), supports only PostgreSQL
69
71
-`-fixtures <...>` fixtures directory
@@ -879,6 +881,49 @@ databases:
879
881
value: value4
880
882
```
881
883
884
+
### MongoDB
885
+
886
+
To connect to MongoDB, you need to:
887
+
- For the CLI-version: use the flags -db-type mongo and mongo_dsn {connectionString};
888
+
- For the Package-version: when configuring the runner, set DbType: fixtures.Mongo and pass the MongoDB client as Mongo: {mongo client}.
889
+
890
+
The format of fixture files for MongoDB:
891
+
```yaml
892
+
collections:
893
+
collection1:
894
+
- field1: "value1"
895
+
field2: 1
896
+
- field1: "value2"
897
+
field2: 2
898
+
field3: 2.569947773654566
899
+
collection2:
900
+
- field4: false
901
+
field5: null
902
+
field1: '"'
903
+
- field1: "'"
904
+
field5:
905
+
- 1
906
+
- '2'
907
+
```
908
+
909
+
If you are using different databases:
910
+
```yaml
911
+
collections:
912
+
database1.collection1:
913
+
- f1: value1
914
+
f2: value2
915
+
916
+
database2.collection2:
917
+
- f1: value3
918
+
f2: value4
919
+
920
+
collection3:
921
+
- f1: value5
922
+
f2: value6
923
+
```
924
+
925
+
The `eval` operator is not supported.
926
+
882
927
## Mocks
883
928
884
929
In order to imitate responses from external services, use mocks.
0 commit comments