commit 3fbd9fa650a74eeb0b438f7e2af77b788d00a880
parent f120768d219d12a07cd3bf3ffb546bb45f20b7bf
Author: Matyja Lukas Adam <lukas.matyja@students.bfh.ch>
Date: Mon, 11 Mar 2024 22:43:23 +0100
[testing] use charity id trait
Diffstat:
4 files changed, 33 insertions(+), 13 deletions(-)
diff --git a/src/include/donau_testing_lib.h b/src/include/donau_testing_lib.h
@@ -62,7 +62,6 @@ TALER_TESTING_cmd_get_donau (
*/
struct TALER_TESTING_Command
TALER_TESTING_cmd_charity_get (const char *label,
- const uint64_t charity_id,
const char *charity_reference,
const struct DONAU_BearerToken *bearer,
unsigned int expected_response_code);
@@ -88,7 +87,7 @@ TALER_TESTING_cmd_charity_post (const char *label,
struct TALER_TESTING_Command
TALER_TESTING_cmd_charity_delete (const char *label,
- const uint64_t charity_id,
+ const char *charity_reference,
const struct DONAU_BearerToken *bearer,
unsigned int expected_response_code);
diff --git a/src/testing/test_donau_api.c b/src/testing/test_donau_api.c
@@ -94,17 +94,16 @@ run (void *cls,
&bearer,
MHD_HTTP_CREATED),
TALER_TESTING_cmd_charity_get ("get-charity-by-id",
- 8,
"post-charity", // cmd trait reference
&bearer,
MHD_HTTP_OK),
TALER_TESTING_cmd_charities_get ("get-charities",
&bearer,
MHD_HTTP_OK),
-// TALER_TESTING_cmd_charity_delete("delete-charity",
-// "post-charity", // cmd trait reference
-// &bearer,
-// MHD_HTTP_NO_CONTENT),
+ TALER_TESTING_cmd_charity_delete("delete-charity",
+ "post-charity", // cmd trait reference
+ &bearer,
+ MHD_HTTP_NO_CONTENT),
/* End the suite. */
TALER_TESTING_cmd_end ()
};
diff --git a/src/testing/testing_api_cmd_charity_delete.c b/src/testing/testing_api_cmd_charity_delete.c
@@ -58,6 +58,11 @@ struct StatusState
*/
struct TALER_TESTING_Interpreter *is;
+ /**
+ * Reference to charity post command.
+ */
+ const char *charity_reference;
+
};
@@ -109,6 +114,25 @@ status_run (void *cls,
ss->is = is;
+ /* Get charity id from trait */
+ {
+ const struct TALER_TESTING_Command *charity_post_cmd;
+ const unsigned long long *charity_id;
+
+ charity_post_cmd = TALER_TESTING_interpreter_lookup_command (is,
+ ss->charity_reference);
+
+ if (GNUNET_OK !=
+ TALER_TESTING_get_trait_charity_id (charity_post_cmd,
+ &charity_id))
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (is);
+ return;
+ }
+ ss->charity_id = (uint64_t) *(charity_id);
+ }
+
ss->cgh = DONAU_charity_delete (
TALER_TESTING_interpreter_get_context (is),
"http://localhost:8080/", //TODO: TALER_TESTING_get_donau_url (is),
@@ -145,16 +169,16 @@ status_cleanup (void *cls,
struct TALER_TESTING_Command
TALER_TESTING_cmd_charity_delete (const char *label,
- const uint64_t charity_id,
- const struct DONAU_BearerToken *bearer,
- unsigned int expected_response_code)
+ const char *charity_reference,
+ const struct DONAU_BearerToken *bearer,
+ unsigned int expected_response_code)
{
struct StatusState *ss;
ss = GNUNET_new (struct StatusState);
ss->expected_response_code = expected_response_code;
ss->bearer = bearer;
- ss->charity_id = charity_id;
+ ss->charity_reference = charity_reference;
{
struct TALER_TESTING_Command cmd = {
.cls = ss,
diff --git a/src/testing/testing_api_cmd_charity_get.c b/src/testing/testing_api_cmd_charity_get.c
@@ -168,7 +168,6 @@ status_cleanup (void *cls,
struct TALER_TESTING_Command
TALER_TESTING_cmd_charity_get (const char *label,
- const uint64_t charity_id,
const char *charity_reference,
const struct DONAU_BearerToken *bearer,
unsigned int expected_response_code)
@@ -177,7 +176,6 @@ TALER_TESTING_cmd_charity_get (const char *label,
ss = GNUNET_new (struct StatusState);
ss->expected_response_code = expected_response_code;
ss->bearer = bearer;
- ss->charity_id = charity_id;
ss->charity_reference = charity_reference;
{
struct TALER_TESTING_Command cmd = {