]> git.ipfire.org Git - pakfire.git/commitdiff
tests: Add a very simple test to create a package
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 25 Oct 2022 14:10:22 +0000 (14:10 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 25 Oct 2022 14:10:22 +0000 (14:10 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
.gitignore
Makefile.am
tests/libpakfire/package.c [new file with mode: 0644]

index 949a9b68019f5097f4c8c631baba7d0e594811a2..930f569db483579c8bb202bf17bcebbae770297e 100644 (file)
@@ -29,6 +29,7 @@
 /tests/libpakfire/key
 /tests/libpakfire/main
 /tests/libpakfire/makefile
+/tests/libpakfire/package
 /tests/libpakfire/packager
 /tests/libpakfire/parser
 /tests/libpakfire/progressbar
index 42ca63c758859b2f32befcf57e8f2c888423a843..2baef27000ae0ffb285292983015a8dff51c26a2 100644 (file)
@@ -385,6 +385,7 @@ check_PROGRAMS += \
        tests/libpakfire/jail \
        tests/libpakfire/key \
        tests/libpakfire/makefile \
+       tests/libpakfire/package \
        tests/libpakfire/packager \
        tests/libpakfire/parser \
        tests/libpakfire/progressbar \
@@ -574,6 +575,18 @@ tests_libpakfire_makefile_CFLAGS = \
 tests_libpakfire_makefile_LDADD = \
        $(TESTSUITE_LDADD)
 
+dist_tests_libpakfire_package_SOURECES = \
+       tests/libpakfire/package.c
+
+tests_libpakfire_package_CPPFLAGS = \
+       $(TESTSUITE_CPPFLAGS)
+
+tests_libpakfire_package_CFLAGS = \
+       $(TESTSUITE_CFLAGS)
+
+tests_libpakfire_package_LDADD = \
+       $(TESTSUITE_LDADD)
+
 dist_tests_libpakfire_packager_SOURCES = \
        tests/libpakfire/packager.c
 
diff --git a/tests/libpakfire/package.c b/tests/libpakfire/package.c
new file mode 100644 (file)
index 0000000..b7b6cd7
--- /dev/null
@@ -0,0 +1,52 @@
+/*#############################################################################
+#                                                                             #
+# 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 <stdio.h>
+
+#include <pakfire/package.h>
+#include <pakfire/util.h>
+
+#include "../testsuite.h"
+
+static int test_create(const struct test* t) {
+       struct pakfire_package* pkg = NULL;
+       int r = EXIT_FAILURE;
+
+       ASSERT(pkg = pakfire_package_create(t->pakfire, NULL, "test", "1.0-1", "src"));
+
+       ASSERT_STRING_EQUALS(pakfire_package_get_name(pkg), "test");
+       ASSERT_STRING_EQUALS(pakfire_package_get_evr(pkg), "1.0-1");
+       ASSERT_STRING_EQUALS(pakfire_package_get_arch(pkg), "src");
+
+       // 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);
+
+       return testsuite_run(argc, argv);
+}