From 9d706a01a23e36e1c349d06e7a1be8bb44b7f0d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zg=C3=BCr=20Kesim?= Date: Mon, 10 Jul 2023 10:22:29 +0200 Subject: added expected HTTP-code to logger --- src/include/taler_testing_lib.h | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'src/include') diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h index 332c3a347..8767ee899 100644 --- a/src/include/taler_testing_lib.h +++ b/src/include/taler_testing_lib.h @@ -57,18 +57,44 @@ * * @param is interpreter to fail * @param status unexpected HTTP status code received + * @param expected expected HTTP status code */ -#define TALER_TESTING_unexpected_status(is,status) \ +#define TALER_TESTING_unexpected_status(is,status, expected) \ do { \ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ - "Unexpected response code %u to command %s in %s:%u\n", \ + "Unexpected response code %u (expected: %u) to command %s in %s:%u\n", \ status, \ + expected, \ TALER_TESTING_interpreter_get_current_label (is), \ __FILE__, \ __LINE__); \ TALER_TESTING_interpreter_fail (is); \ } while (0) +/** + * Log an error message about us receiving an unexpected HTTP + * status code at the current command and fail the test and print the response + * body (expected as json). + * + * @param is interpreter to fail + * @param status unexpected HTTP status code received + * @param expected expected HTTP status code + * @param body received JSON-reply + */ +#define TALER_TESTING_unexpected_status_with_body(is,status, expected, body) \ + do { \ + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ + "Unexpected response code %u (expected: %u) to " \ + "command %s in %s:%u\nwith body:\n>>%s<<\n", \ + status, \ + expected, \ + TALER_TESTING_interpreter_get_current_label (is), \ + __FILE__, \ + __LINE__, \ + json_dumps (body, JSON_INDENT (2))); \ + TALER_TESTING_interpreter_fail (is); \ + } while (0) + /** * Log an error message about a command not having -- cgit v1.2.3