Source
/*
** Zabbix
** Copyright (C) 2001-2023 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
static int num_params_exp = 0, num_params_rec = 0;
static int num_metrics_exp = 0;
static void check_param(const char *name, const char *value, const struct zbx_json_parse *jp)
{
char *json_value = NULL;
size_t json_value_sz = 0;
int ret;
ret = zbx_json_value_by_name_dyn(jp, name, &json_value, &json_value_sz, NULL);
if (SUCCEED != ret)
fail_msg("Expected parameter/label (%s) is not found in JSON output", name);
zbx_mock_assert_str_eq("Invalid parameter/label value returned by zbx_prometheus_to_json()", value, json_value);
zbx_free(json_value);
num_params_exp++;
}
static void check_metric_param(zbx_mock_handle_t element, const char *name, const struct zbx_json_parse *jp)
{
const char *value;
zbx_mock_handle_t member;
zbx_mock_error_t err;
if (ZBX_MOCK_SUCCESS == zbx_mock_object_member(element, name, &member))
{
if (ZBX_MOCK_SUCCESS != (err = zbx_mock_string(member, &value)))
fail_msg("Cannot get string: %s", zbx_mock_error_string(err));
check_param(name, value, jp);
}
}
void zbx_mock_test_entry(void **state)