#include <stdio.h>
+#include <uuid/uuid.h>
+
#include <pakfire/package.h>
#include <pakfire/util.h>
return r;
}
+static int test_uuid(const struct test* t) {
+ struct pakfire_package* pkg = NULL;
+ int r = EXIT_FAILURE;
+
+ uuid_t uuid;
+ char uuid_string[UUID_STR_LEN];
+
+ // Generate a new random UUID
+ uuid_generate_random(uuid);
+
+ // Convert the UUID to string
+ uuid_unparse(uuid, uuid_string);
+
+ // Create a new package
+ ASSERT_SUCCESS(pakfire_package_create(&pkg, t->pakfire, NULL, "test", "1.0-1", "src"));
+
+ // Set the UUID
+ ASSERT_SUCCESS(pakfire_package_set_uuid(pkg, PAKFIRE_PKG_UUID, uuid));
+
+ // Fetch the UUID as string
+ ASSERT_STRING_EQUALS(pakfire_package_get_string(pkg, PAKFIRE_PKG_UUID), uuid_string);
+
+ // Set the Build ID
+ ASSERT_SUCCESS(pakfire_package_set_uuid(pkg, PAKFIRE_PKG_BUILD_ID, uuid));
+
+ // Fetch the Build ID as string
+ ASSERT_STRING_EQUALS(pakfire_package_get_string(pkg, PAKFIRE_PKG_BUILD_ID), uuid_string);
+
+ // Try setting the UUID as something else
+ ASSERT_ERRNO(pakfire_package_set_uuid(pkg, PAKFIRE_PKG_SUMMARY, uuid), EINVAL);
+
+ // Everything passed
+ r = EXIT_SUCCESS;
+
+FAIL:
+ if (pkg)
+ pakfire_package_unref(pkg);
+
+ return r;
+}
+
static int test_deps(const struct test* t) {
struct pakfire_package* pkg = NULL;
char** deps = NULL;
int main(int argc, const char* argv[]) {
testsuite_add_test(test_create);
+ testsuite_add_test(test_uuid);
testsuite_add_test(test_deps);
return testsuite_run(argc, argv);