]> git.ipfire.org Git - pakfire.git/commitdiff
libpakfire: tests: Add test to import a package
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 8 Jun 2019 12:15:34 +0000 (13:15 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 8 Jun 2019 12:15:34 +0000 (13:15 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
tests/libpakfire/archive.c

index fce6c1e0ca4b59e11f1644b84965bc3c1a27dce9..3280d264b21945f8ec1c273a763f68a362e99df6 100644 (file)
@@ -21,6 +21,7 @@
 #include <unistd.h>
 
 #include <pakfire/archive.h>
+#include <pakfire/repo.h>
 #include <pakfire/util.h>
 
 #include "../testsuite.h"
@@ -65,13 +66,32 @@ int test_extract(const test_t* t) {
        return EXIT_SUCCESS;
 }
 
+int test_import(const test_t* t) {
+       char* path = pakfire_path_join(TEST_SRC_PATH, TEST_PKG1_PATH);
+
+       PakfireArchive archive = pakfire_archive_open(t->pakfire, path);
+       pakfire_free(path);
+
+       PakfireRepo repo = pakfire_repo_create(t->pakfire, "tmp");
+       assert_return(repo, EXIT_FAILURE);
+
+       PakfirePackage pkg = pakfire_repo_add_archive(repo, archive);
+       assert_return(pkg, EXIT_FAILURE);
+
+       pakfire_repo_unref(repo);
+       pakfire_archive_unref(archive);
+
+       return EXIT_SUCCESS;
+}
+
 int main(int argc, char** argv) {
        testsuite_init();
 
-       testsuite_t* ts = testsuite_create(2);
+       testsuite_t* ts = testsuite_create(3);
 
        testsuite_add_test(ts, "test_open", test_open);
        testsuite_add_test(ts, "test_extract", test_extract);
+       testsuite_add_test(ts, "test_import", test_import);
 
        return testsuite_run(ts);
 }