From: Michael Tremer Date: Sat, 8 Jun 2019 12:15:34 +0000 (+0100) Subject: libpakfire: tests: Add test to import a package X-Git-Tag: 0.9.28~1285^2~976 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d55bc51496752461674ddc2b7e0073f31a5b974f;p=pakfire.git libpakfire: tests: Add test to import a package Signed-off-by: Michael Tremer --- diff --git a/tests/libpakfire/archive.c b/tests/libpakfire/archive.c index fce6c1e0c..3280d264b 100644 --- a/tests/libpakfire/archive.c +++ b/tests/libpakfire/archive.c @@ -21,6 +21,7 @@ #include #include +#include #include #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); }