]> git.ipfire.org Git - pakfire.git/commitdiff
tests: Add a simple test for xfers
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 1 Nov 2023 14:51:44 +0000 (14:51 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 1 Nov 2023 14:51:44 +0000 (14:51 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
.gitignore
Makefile.am
tests/libpakfire/xfer.c [new file with mode: 0644]

index fca65496ad07a076d4fe5af57aa32d7594b92b3e..a2a7678bc66641f08f1282204bde3a29b8ddd033 100644 (file)
@@ -41,6 +41,7 @@
 /tests/libpakfire/snapshot
 /tests/libpakfire/string
 /tests/libpakfire/util
+/tests/libpakfire/xfer
 /tests/parser/test
 /tests/stub/root
 /tmp
index 660ec4b107c6a04af41f2c529f880bd3cf4a8d24..aa1e0de0cd949526d73b0d8d889b98658adef80e 100644 (file)
@@ -613,7 +613,8 @@ check_PROGRAMS += \
        tests/libpakfire/repo \
        tests/libpakfire/snapshot \
        tests/libpakfire/string \
-       tests/libpakfire/util
+       tests/libpakfire/util \
+       tests/libpakfire/xfer
 
 dist_tests_libpakfire_main_SOURCES = \
        tests/libpakfire/main.c
@@ -915,6 +916,18 @@ tests_libpakfire_util_CFLAGS = \
 tests_libpakfire_util_LDADD = \
        $(TESTSUITE_LDADD)
 
+dist_tests_libpakfire_xfer_SOURCES = \
+       tests/libpakfire/xfer.c
+
+tests_libpakfire_xfer_CPPFLAGS = \
+       $(TESTSUITE_CPPFLAGS)
+
+tests_libpakfire_xfer_CFLAGS = \
+       $(TESTSUITE_CFLAGS)
+
+tests_libpakfire_xfer_LDADD = \
+       $(TESTSUITE_LDADD)
+
 # ------------------------------------------------------------------------------
 
 noinst_PROGRAMS += \
diff --git a/tests/libpakfire/xfer.c b/tests/libpakfire/xfer.c
new file mode 100644 (file)
index 0000000..1b2ddf8
--- /dev/null
@@ -0,0 +1,46 @@
+/*#############################################################################
+#                                                                             #
+# Pakfire - The IPFire package management system                              #
+# Copyright (C) 2023 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/xfer.h>
+
+#include "../testsuite.h"
+
+static int test_create(const struct test* t) {
+       struct pakfire_xfer* xfer = NULL;
+       int r = EXIT_FAILURE;
+
+       // Create a new transfer
+       ASSERT_SUCCESS(pakfire_xfer_create(&xfer, t->ctx, t->httpclient, "file://invalid"));
+
+       // Everything passed
+       r = EXIT_SUCCESS;
+
+FAIL:
+       if (xfer)
+               pakfire_xfer_unref(xfer);
+
+       return r;
+}
+
+int main(int argc, const char* argv[]) {
+       testsuite_add_test(test_create, TEST_WANTS_HTTPCLIENT);
+
+       return testsuite_run(argc, argv);
+}