Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
}
}
+ // Create a HTTP client (if requested)
+ if (t->flags & TEST_WANTS_HTTPCLIENT) {
+ r = pakfire_httpclient_create(&t->httpclient, t->ctx);
+ if (r) {
+ LOG("ERROR: Could not initialize the HTTP client: %s\n", strerror(-r));
+ goto ERROR;
+ }
+ }
+
// Run test
r = t->func(t);
if (r)
LOG("Test failed with error code: %d\n", r);
ERROR:
+ // Release HTTP client
+ if (t->httpclient)
+ pakfire_httpclient_unref(t->httpclient);
+
// Release pakfire
if (t->pakfire) {
p = pakfire_unref(t->pakfire);
#include <string.h>
#include <pakfire/ctx.h>
+#include <pakfire/httpclient.h>
#include <pakfire/pakfire.h>
#define MAX_TESTS 128
#define TEST_SRC_PATH ABS_TOP_SRCDIR "/tests/"
enum test_flags {
- TEST_WANTS_PAKFIRE = (1 << 0),
+ TEST_WANTS_PAKFIRE = (1 << 0),
+ TEST_WANTS_HTTPCLIENT = (1 << 1),
};
struct test {
// Pakfire
struct pakfire* pakfire;
+
+ // HTTP Client
+ struct pakfire_httpclient* httpclient;
};
struct testsuite {