diff options
author | Christian Grothoff <christian@grothoff.org> | 2022-12-21 13:29:12 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2022-12-21 13:29:12 +0100 |
commit | ac4225f09f31dd59135c874f8658e3c514b9d131 (patch) | |
tree | 61a2633cc20b8a30a76b219dc116d7cd0ee96d78 /src | |
parent | 32db715dcd16aa3ab72c61c4961351906a3a7e76 (diff) |
typo
Diffstat (limited to 'src')
-rw-r--r-- | src/backenddb/test_merchantdb.c | 160 |
1 files changed, 76 insertions, 84 deletions
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c index 534eef81..589d14a4 100644 --- a/src/backenddb/test_merchantdb.c +++ b/src/backenddb/test_merchantdb.c @@ -6834,9 +6834,6 @@ test_kyc (void) } - - - /* *********** Templates ********** */ /** @@ -6864,7 +6861,7 @@ struct TemplateData */ static void make_template (const char *id, - struct TemplateData *template) + struct TemplateData *template) { template->id = id; template->template.template_description = "This is a test template"; @@ -6897,7 +6894,7 @@ free_template_data (struct TemplateData *template) */ static int check_templates_equal (const struct TALER_MERCHANTDB_TemplateDetails *a, - const struct TALER_MERCHANTDB_TemplateDetails *b) + const struct TALER_MERCHANTDB_TemplateDetails *b) { if ((0 != strcmp (a->template_description, b->template_description)) || @@ -6920,14 +6917,14 @@ check_templates_equal (const struct TALER_MERCHANTDB_TemplateDetails *a, */ static int test_insert_template (const struct InstanceData *instance, - const struct TemplateData *template, - enum GNUNET_DB_QueryStatus expected_result) + const struct TemplateData *template, + enum GNUNET_DB_QueryStatus expected_result) { TEST_COND_RET_ON_FAIL (expected_result == plugin->insert_template (plugin->cls, - instance->instance.id, - template->id, - &template->template), + instance->instance.id, + template->id, + &template->template), "Insert template failed\n"); return 0; } @@ -6943,14 +6940,14 @@ test_insert_template (const struct InstanceData *instance, */ static int test_update_template (const struct InstanceData *instance, - const struct TemplateData *template, - enum GNUNET_DB_QueryStatus expected_result) + const struct TemplateData *template, + enum GNUNET_DB_QueryStatus expected_result) { TEST_COND_RET_ON_FAIL (expected_result == plugin->update_template (plugin->cls, - instance->instance.id, - template->id, - &template->template), + instance->instance.id, + template->id, + &template->template), "Update template failed\n"); return 0; } @@ -6965,13 +6962,13 @@ test_update_template (const struct InstanceData *instance, */ static int test_lookup_template (const struct InstanceData *instance, - const struct TemplateData *template) + const struct TemplateData *template) { struct TALER_MERCHANTDB_TemplateDetails lookup_result; if (0 > plugin->lookup_template (plugin->cls, - instance->instance.id, - template->id, - &lookup_result)) + instance->instance.id, + template->id, + &lookup_result)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Lookup template failed\n"); @@ -6980,14 +6977,14 @@ test_lookup_template (const struct InstanceData *instance, } const struct TALER_MERCHANTDB_TemplateDetails *to_cmp = &template->template; if (0 != check_templates_equal (&lookup_result, - to_cmp)) + to_cmp)) { GNUNET_break (0); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Lookup template failed: incorrect template returned\n"); TALER_MERCHANTDB_template_details_free (&lookup_result); return 1; - }5 + } TALER_MERCHANTDB_template_details_free (&lookup_result); return 0; } @@ -7054,8 +7051,8 @@ lookup_templates_cb (void *cls, */ static int test_lookup_templates (const struct InstanceData *instance, - unsigned int templates_length, - const struct TemplateData *templates) + unsigned int templates_length, + const struct TemplateData *templates) { unsigned int results_matching[templates_length]; struct TestLookupTemplates_Closure cls = { @@ -7066,9 +7063,9 @@ test_lookup_templates (const struct InstanceData *instance, }; memset (results_matching, 0, sizeof (unsigned int) * templates_length); if (0 > plugin->lookup_templates (plugin->cls, - instance->instance.id, - &lookup_templates_cb, - &cls)) + instance->instance.id, + &lookup_templates_cb, + &cls)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Lookup templates failed\n"); @@ -7103,13 +7100,13 @@ test_lookup_templates (const struct InstanceData *instance, */ static int test_delete_template (const struct InstanceData *instance, - const struct TemplateData *template, - enum GNUNET_DB_QueryStatus expected_result) + const struct TemplateData *template, + enum GNUNET_DB_QueryStatus expected_result) { TEST_COND_RET_ON_FAIL (expected_result == plugin->delete_template (plugin->cls, - instance->instance.id, - template->id), + instance->instance.id, + template->id), "Delete template failed\n"); return 0; } @@ -7146,11 +7143,12 @@ pre_test_templates (struct TestTemplates_Closure *cls) /* Templates */ make_template ("test_templates_pd_0", - &cls->templates[0]); + &cls->templates[0]); make_template ("test_templates_pd_1", - &cls->templates[1]); - cls->templates[1].template.template_description = "This is a another test template"; + &cls->templates[1]); + cls->templates[1].template.template_description = + "This is a another test template"; } @@ -7180,28 +7178,28 @@ run_test_templates (struct TestTemplates_Closure *cls) /* Test that insert without an instance fails */ TEST_RET_ON_FAIL (test_insert_template (&cls->instance, - &cls->templates[0], - GNUNET_DB_STATUS_SUCCESS_NO_RESULTS)); + &cls->templates[0], + GNUNET_DB_STATUS_SUCCESS_NO_RESULTS)); /* Insert the instance */ TEST_RET_ON_FAIL (test_insert_instance (&cls->instance, GNUNET_DB_STATUS_SUCCESS_ONE_RESULT)); /* Test inserting a template */ TEST_RET_ON_FAIL (test_insert_template (&cls->instance, - &cls->templates[0], - GNUNET_DB_STATUS_SUCCESS_ONE_RESULT)); + &cls->templates[0], + GNUNET_DB_STATUS_SUCCESS_ONE_RESULT)); /* Test that double insert fails */ TEST_RET_ON_FAIL (test_insert_template (&cls->instance, - &cls->templates[0], - GNUNET_DB_STATUS_SUCCESS_NO_RESULTS)); + &cls->templates[0], + GNUNET_DB_STATUS_SUCCESS_NO_RESULTS)); /* Test lookup of individual templates */ TEST_RET_ON_FAIL (test_lookup_template (&cls->instance, - &cls->templates[0])); + &cls->templates[0])); /* Make sure it fails correctly for templates that don't exist */ if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != plugin->lookup_template (plugin->cls, - cls->instance.instance.id, - "nonexistent_template", - NULL)) + cls->instance.instance.id, + "nonexistent_template", + NULL)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Lookup template failed\n"); @@ -7213,36 +7211,37 @@ run_test_templates (struct TestTemplates_Closure *cls) GNUNET_free (cls->templates[0].template.image); cls->templates[0].template.image = GNUNET_strdup ("image"); GNUNET_assert (0 == - json_array_append_new (cls->templates[0].template.template_contract, - json_string ("This is a test. 3CH."))); + json_array_append_new ( + cls->templates[0].template.template_contract, + json_string ("This is a test. 3CH."))); TEST_RET_ON_FAIL (test_update_template (&cls->instance, - &cls->templates[0], - GNUNET_DB_STATUS_SUCCESS_ONE_RESULT)); + &cls->templates[0], + GNUNET_DB_STATUS_SUCCESS_ONE_RESULT)); TEST_RET_ON_FAIL (test_lookup_template (&cls->instance, - &cls->templates[0])); + &cls->templates[0])); TEST_RET_ON_FAIL (test_update_template (&cls->instance, - &cls->templates[1], - GNUNET_DB_STATUS_SUCCESS_NO_RESULTS)); + &cls->templates[1], + GNUNET_DB_STATUS_SUCCESS_NO_RESULTS)); /* Test collective template lookup */ TEST_RET_ON_FAIL (test_insert_template (&cls->instance, - &cls->templates[1], - GNUNET_DB_STATUS_SUCCESS_ONE_RESULT)); + &cls->templates[1], + GNUNET_DB_STATUS_SUCCESS_ONE_RESULT)); TEST_RET_ON_FAIL (test_lookup_templates (&cls->instance, - 2, - cls->templates)); + 2, + cls->templates)); /* Test template deletion */ TEST_RET_ON_FAIL (test_delete_template (&cls->instance, - &cls->templates[1], - GNUNET_DB_STATUS_SUCCESS_ONE_RESULT)); + &cls->templates[1], + GNUNET_DB_STATUS_SUCCESS_ONE_RESULT)); /* Test double deletion fails */ TEST_RET_ON_FAIL (test_delete_template (&cls->instance, - &cls->templates[1], - GNUNET_DB_STATUS_SUCCESS_NO_RESULTS)); + &cls->templates[1], + GNUNET_DB_STATUS_SUCCESS_NO_RESULTS)); TEST_RET_ON_FAIL (test_lookup_templates (&cls->instance, - 1, - cls->templates)); + 1, + cls->templates)); return 0; } @@ -7293,15 +7292,14 @@ make_webhook (const char *id, struct WebhookData *webhook) { webhook->id = id; - webhook->webhook.event_type= "Paid"; - webhook->webhook.url= "https://example.com"; - webhook->webhook.http_method= "POST"; - webhook->webhook.header_template= "Authorization:XYJAORKJEO"; - webhook->webhook.body_template= "$Amount"; + webhook->webhook.event_type = "Paid"; + webhook->webhook.url = "https://example.com"; + webhook->webhook.http_method = "POST"; + webhook->webhook.header_template = "Authorization:XYJAORKJEO"; + webhook->webhook.body_template = "$Amount"; } - /** * Compare two webhooks for equality. * @@ -7446,8 +7444,8 @@ struct TestLookupWebhooks_Closure */ static void lookup_webhooks_cb (void *cls, - const char *webhook_id, - const char *event_type) + const char *webhook_id, + const char *event_type) { struct TestLookupWebhooks_Closure *cmp = cls; if (NULL == cmp) @@ -7568,7 +7566,7 @@ pre_test_webhooks (struct TestWebhooks_Closure *cls) make_webhook ("test_webhooks_wb_1", &cls->webhooks[1]); - cls->webhooks[1].webhook.event_type= "Test paid"; + cls->webhooks[1].webhook.event_type = "Test paid"; } @@ -7624,15 +7622,15 @@ run_test_webhooks (struct TestWebhooks_Closure *cls) return 1; } /* Test webhook update */ - cls->webhooks[0].webhook.event_type= + cls->webhooks[0].webhook.event_type = "Test paid"; - cls->webhooks[0].webhook.url= + cls->webhooks[0].webhook.url = "https://example.com"; - cls->webhooks[0].webhook.http_method= + cls->webhooks[0].webhook.http_method = "POST"; - cls->webhooks[0].webhook.header_template= + cls->webhooks[0].webhook.header_template = "Authorization:WEKFOEKEXZ"; - cls->webhooks[0].webhook.body_template= + cls->webhooks[0].webhook.body_template = "$Amount"; TEST_RET_ON_FAIL (test_update_webhook (&cls->instance, &cls->webhooks[0], @@ -7682,8 +7680,6 @@ test_webhooks (void) } - - /** * Function that runs all tests. * @@ -7707,7 +7703,6 @@ run_tests (void) } - /** * Main function that will be run by the scheduler. * @@ -7743,9 +7738,9 @@ run (void *cls) plugin->preflight (plugin->cls); result = run_tests (); - if (0 == result) - /** result = run_test_templates (); - if (0 == result)*/ + if (0 == result) + /** result = run_test_templates (); + if (0 == result)*/ { /* Test dropping tables */ if (GNUNET_OK != plugin->drop_tables (plugin->cls)) @@ -7762,8 +7757,6 @@ run (void *cls) } - - /** * Entry point for the tests. */ @@ -7791,7 +7784,7 @@ main (int argc, (void) GNUNET_asprintf (&config_filename, "%s.conf", testname); - fprintf(stdout, "Using %s\n", config_filename); + fprintf (stdout, "Using %s\n", config_filename); cfg = GNUNET_CONFIGURATION_create (); if (GNUNET_OK != GNUNET_CONFIGURATION_parse (cfg, @@ -7811,5 +7804,4 @@ main (int argc, } - /* end of test_merchantdb.c */ |