]> git.ipfire.org Git - pakfire.git/commitdiff
tests: Add a simple test for package dependencies
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 26 Oct 2022 17:59:47 +0000 (17:59 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 26 Oct 2022 17:59:47 +0000 (17:59 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
tests/libpakfire/package.c

index 485723fba2d5f09673a64943cffcfc009575a4e8..1628a7382ff20403aee9a4064d66caa392a4b1d7 100644 (file)
@@ -49,8 +49,37 @@ FAIL:
        return r;
 }
 
+static int test_deps(const struct test* t) {
+       struct pakfire_package* pkg = NULL;
+       char** deps = NULL;
+       int r = EXIT_FAILURE;
+
+       ASSERT_SUCCESS(pakfire_package_create(&pkg, t->pakfire, NULL, "test", "1.0-1", "src"));
+
+       // Add a "provides"
+       ASSERT_SUCCESS(pakfire_package_add_dep(pkg, PAKFIRE_PKG_PROVIDES, "a"));
+
+       // Fetch the provides
+       ASSERT(deps = pakfire_package_get_deps(pkg, PAKFIRE_PKG_PROVIDES));
+
+       // There should be one element called "a"
+       for (char** dep = deps; *dep; dep++) {
+               ASSERT_STRING_EQUALS(*dep, "a");
+       }
+
+       // Everything passed
+       r = EXIT_SUCCESS;
+
+FAIL:
+       if (pkg)
+               pakfire_package_unref(pkg);
+
+       return r;
+}
+
 int main(int argc, const char* argv[]) {
        testsuite_add_test(test_create);
+       testsuite_add_test(test_deps);
 
        return testsuite_run(argc, argv);
 }