-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add query hook for any API method (#53)
## What does this PR do? When no command is found, Kourou will try to execute the given command with the `sdk:query` command. The first argument has to be the name of the controller and the action separated by a semicolon (eg `document:create`) Kourou will try to infer common arguments like `index`, `collection`, `_id` or `body`. It will automatically infer and accept the following lists of arguments: - `<command> <index>` * _eg: `kourou collection:list iot`_ . - `<command> <index> <collection>` * _eg: `kourou collection:truncate iot sensors`_ . - `<command> <index> <collection> <body>` * _eg: `kourou bulk:import iot sensors '{bulkData: []}'`_ . - `<command> <index> <collection> <id>` * _eg: `kourou document:delete iot sensors sigfox-123`_ . - `<command> <index> <collection> <id> <body>` * _eg: `kourou document:create iot sensors sigfox-123 '{temperature: 42}'`_ Then any argument will be passed as-is to the `sdk:query` method. ### Other changes - add `--id` argument to `sdk:query` - remove `document:get` - remove `document:create`
- Loading branch information
Showing
11 changed files
with
277 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
Feature: Hooks | ||
|
||
# command_not_found hook ===================================================== | ||
|
||
@mappings | ||
Scenario: Unregistered API method | ||
Given an existing collection "nyc-open-data":"yellow-taxi" | ||
When I run the command "document:createOrReplace" with: | ||
| flag | --arg | index=nyc-open-data | | ||
| flag | --arg | collection=yellow-taxi | | ||
| flag | -a | _id=chuon-chuon-kim | | ||
| flag | --body | { "other-name": "my" } | | ||
Then The document "chuon-chuon-kim" content match: | ||
| other-name | "my" | | ||
|
||
@mappings | ||
Scenario: Infer common arguments | ||
Given an existing collection "nyc-open-data":"yellow-taxi" | ||
# <command> <index> | ||
When I run the command "collection:list" with: | ||
| arg | nyc-open-data | | | ||
Then I should match stdout with "yellow-taxi" | ||
# <command> <index> <collection> | ||
When I run the command "collection:truncate" with: | ||
| arg | nyc-open-data | | | ||
| arg | yellow-taxi | | | ||
Then I should match stdout with "acknowledged" | ||
# <command> <index> <collection> <id> <body> | ||
When I run the command "document:createOrReplace" with: | ||
| arg | nyc-open-data | | | ||
| arg | yellow-taxi | | | ||
| arg | foobar-1 | | | ||
| arg | {helloWorld: 42} | | | ||
Then I should match stdout with "helloWorld" | ||
# <command> <index> <collection> <id> | ||
When I run the command "document:delete" with: | ||
| arg | nyc-open-data | | | ||
| arg | yellow-taxi | | | ||
| arg | foobar-1 | | | ||
Then I should match stdout with "foobar-1" | ||
# <command> <index> <collection> <body> | ||
When I run the command "collection:updateMapping" with: | ||
| arg | nyc-open-data | | | ||
| arg | yellow-taxi | | | ||
| arg | { dynamic: "false" } | | | ||
Then I should match stdout with "false" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.