]> git.ipfire.org Git - pakfire.git/commitdiff
packager: Add some basic tests
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 5 Mar 2021 17:27:04 +0000 (17:27 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 5 Mar 2021 17:27:04 +0000 (17:27 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
.gitignore
Makefile.am
tests/libpakfire/packager.c [new file with mode: 0644]

index fdc0776ddac15502e0707e7b1cd16bc8c4d363ce..a559bbfc732a4378dca2469c5aa0ee8d08e5b9e5 100644 (file)
@@ -17,6 +17,7 @@
 /tests/libpakfire/key
 /tests/libpakfire/main
 /tests/libpakfire/makefile
+/tests/libpakfire/packager
 /tests/libpakfire/parser
 /tests/libpakfire/repo
 /tests/libpakfire/util
index 79a581b57854e7b27ef938a35f228a9676b2f669..701029e8ead2c8f6c0861da8685645b28265f35a 100644 (file)
@@ -365,6 +365,7 @@ check_PROGRAMS += \
        tests/libpakfire/execute \
        tests/libpakfire/key \
        tests/libpakfire/makefile \
+       tests/libpakfire/packager \
        tests/libpakfire/parser \
        tests/libpakfire/repo \
        tests/libpakfire/util
@@ -442,6 +443,16 @@ tests_libpakfire_makefile_LDADD = \
        $(TESTSUITE_LDADD) \
        $(PAKFIRE_LIBS)
 
+dist_tests_libpakfire_packager_SOURCES = \
+       tests/libpakfire/packager.c
+
+tests_libpakfire_packager_CPPFLAGS = \
+       $(TESTSUITE_CPPFLAGS)
+
+tests_libpakfire_packager_LDADD = \
+       $(TESTSUITE_LDADD) \
+       $(PAKFIRE_LIBS)
+
 dist_tests_libpakfire_parser_SOURCES = \
        tests/libpakfire/parser.c
 
diff --git a/tests/libpakfire/packager.c b/tests/libpakfire/packager.c
new file mode 100644 (file)
index 0000000..862102a
--- /dev/null
@@ -0,0 +1,53 @@
+/*#############################################################################
+#                                                                             #
+# Pakfire - The IPFire package management system                              #
+# Copyright (C) 2021 Pakfire development team                                 #
+#                                                                             #
+# This program is free software: you can redistribute it and/or modify        #
+# it under the terms of the GNU General Public License as published by        #
+# the Free Software Foundation, either version 3 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+#############################################################################*/
+
+#include <pakfire/package.h>
+#include <pakfire/packager.h>
+#include <pakfire/repo.h>
+
+#include "../testsuite.h"
+
+static int test_create(const struct test* t) {
+       struct pakfire_packager* packager;
+
+       PakfireRepo repo = pakfire_repo_create(t->pakfire, "test");
+       ASSERT(repo);
+
+       PakfirePackage pkg = pakfire_package_create(t->pakfire, repo,
+               "test", "1.0-1", "src");
+       ASSERT(pkg);
+
+       // Create packager
+       int r = pakfire_packager_create(&packager, pkg);
+       ASSERT(r == 0);
+       
+       // Cleanup
+       pakfire_packager_unref(packager);
+       pakfire_package_unref(pkg);
+       pakfire_repo_unref(repo);
+
+       return EXIT_SUCCESS;
+}
+
+int main(int argc, char** argv) {
+       testsuite_add_test(test_create);
+
+       return testsuite_run();
+}