diff options
author | Andris Zeila <andris.zeila@zabbix.com> | 2020-03-13 16:05:05 +0300 |
---|---|---|
committer | Andris Zeila <andris.zeila@zabbix.com> | 2020-03-13 16:07:38 +0300 |
commit | 25250c2025dd4c6ae94d6dd28d0dbf86d0b8f668 (patch) | |
tree | 640f97cfbbb52f4af80149283ad0d70099ac559c /tests/libs/zbxjson | |
parent | fc64cd234aa1d734d22e5ac1c30293e4a1e06a24 (diff) |
.......PS. [ZBXNEXT-5649] added name referencing support ('~' suffix) to jsonpath
* commit 'c20dc2e3aeebad34751e4e7e236b0f0bc895b062':
.......... [ZBXNEXT-5649] added changelog entry
.......PS. [ZBXNEXT-5649] coding style fixes
.......PS. [ZBXNEXT-5649] fixed coding style issues
.......PS. [ZBXNEXT-5649] fixed coding style issues and removed debug logging from tests
.......PS. [ZBXNEXT-5649] added name referencing support ('~' suffix) to jsonpath
(cherry picked from commit fd0b126ceb67031c49051d4820dc2c0d8ce0a0e2)
Diffstat (limited to 'tests/libs/zbxjson')
-rw-r--r-- | tests/libs/zbxjson/zbx_jsonpath_compile.c | 3 | ||||
-rw-r--r-- | tests/libs/zbxjson/zbx_jsonpath_compile.yaml | 36 | ||||
-rw-r--r-- | tests/libs/zbxjson/zbx_jsonpath_query.yaml | 37 |
3 files changed, 74 insertions, 2 deletions
diff --git a/tests/libs/zbxjson/zbx_jsonpath_compile.c b/tests/libs/zbxjson/zbx_jsonpath_compile.c index 1968861b69c..6f24859aed2 100644 --- a/tests/libs/zbxjson/zbx_jsonpath_compile.c +++ b/tests/libs/zbxjson/zbx_jsonpath_compile.c @@ -115,7 +115,8 @@ static void jsonpath_token_print(char **data, size_t *data_alloc, size_t *data_o static char *segment_data_to_str(const zbx_jsonpath_segment_t *segment) { - const char *functions[] = {"unknown", "min()", "max()", "avg()", "length()", "first()"}; + const char *functions[] = {"unknown", "min()", "max()", "avg()", "length()", "first()", + "sum()", "~"}; char *data = NULL; size_t data_alloc = 0, data_offset = 0; int i; diff --git a/tests/libs/zbxjson/zbx_jsonpath_compile.yaml b/tests/libs/zbxjson/zbx_jsonpath_compile.yaml index 36e031402bb..0a203a61f5a 100644 --- a/tests/libs/zbxjson/zbx_jsonpath_compile.yaml +++ b/tests/libs/zbxjson/zbx_jsonpath_compile.yaml @@ -1035,4 +1035,40 @@ out: - type: ZBX_JSONPATH_SEGMENT_MATCH_LIST data: "'connections'" detached: 0 +--- +test case: Compile success $.sum() +in: + path: $.sum() +out: + result: SUCCEED + definite: 1 + segments: + - type: ZBX_JSONPATH_SEGMENT_FUNCTION + data: "sum()" +--- +test case: Compile success $.*~ +in: + path: $.*~ +out: + result: SUCCEED + definite: 0 + segments: + - type: ZBX_JSONPATH_SEGMENT_MATCH_ALL + data: "*" + - type: ZBX_JSONPATH_SEGMENT_FUNCTION + data: "~" +--- +test case: Compile success $.*~.first() +in: + path: $.*~.first() +out: + result: SUCCEED + definite: 0 + segments: + - type: ZBX_JSONPATH_SEGMENT_MATCH_ALL + data: "*" + - type: ZBX_JSONPATH_SEGMENT_FUNCTION + data: "~" + - type: ZBX_JSONPATH_SEGMENT_FUNCTION + data: "first()" ... diff --git a/tests/libs/zbxjson/zbx_jsonpath_query.yaml b/tests/libs/zbxjson/zbx_jsonpath_query.yaml index a775a67a707..a4b784b90d9 100644 --- a/tests/libs/zbxjson/zbx_jsonpath_query.yaml +++ b/tests/libs/zbxjson/zbx_jsonpath_query.yaml @@ -723,5 +723,40 @@ in: out: return: SUCCEED values: '[2]' +--- +test case: Query $.*~ +include: &include zbx_jsonpath_query.inc.yaml +in: + data: *include + path: $.*~ +out: + return: SUCCEED + value: '["books","services","filters","closed message","tags"]' +--- +test case: Query $.*~.first() +include: &include zbx_jsonpath_query.inc.yaml +in: + data: *include + path: $.*~.first() +out: + return: SUCCEED + value: 'books' +--- +test case: Query $.services[?(@.servicegroup=="1002")]~ +include: &include zbx_jsonpath_query.inc.yaml +in: + data: *include + path: $.services[?(@.servicegroup=="1002")]~ +out: + return: SUCCEED + value: '["restoration"]' +--- +test case: Query $.books[?(@.category=="fiction")]~ +include: &include zbx_jsonpath_query.inc.yaml +in: + data: *include + path: $.books[?(@.category=="fiction")]~ +out: + return: SUCCEED + value: '["1","2","3"]' ... - |