From: Michael Tremer Date: Fri, 22 Jan 2021 18:10:59 +0000 (+0000) Subject: tests: Add some tests for database X-Git-Tag: 0.9.28~1285^2~816 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=746e9da5068e365f08ff41f6df6d284a68276d69;p=pakfire.git tests: Add some tests for database Signed-off-by: Michael Tremer --- diff --git a/.gitignore b/.gitignore index a9a2f0f7..a4fe5de2 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ /tests/.root /tests/libpakfire/arch /tests/libpakfire/archive +/tests/libpakfire/db /tests/libpakfire/execute /tests/libpakfire/key /tests/libpakfire/main diff --git a/Makefile.am b/Makefile.am index 79c0d697..8732f858 100644 --- a/Makefile.am +++ b/Makefile.am @@ -357,6 +357,7 @@ check_PROGRAMS += \ tests/libpakfire/main \ tests/libpakfire/arch \ tests/libpakfire/archive \ + tests/libpakfire/db \ tests/libpakfire/execute \ tests/libpakfire/key \ tests/libpakfire/makefile \ @@ -394,6 +395,16 @@ tests_libpakfire_archive_LDADD = \ $(TESTSUITE_LDADD) \ $(PAKFIRE_LIBS) +tests_libpakfire_db_SOURCES = \ + tests/libpakfire/db.c + +tests_libpakfire_db_CPPFLAGS = \ + $(TESTSUITE_CPPFLAGS) + +tests_libpakfire_db_LDADD = \ + $(TESTSUITE_LDADD) \ + $(PAKFIRE_LIBS) + tests_libpakfire_execute_SOURCES = \ tests/libpakfire/execute.c diff --git a/tests/libpakfire/db.c b/tests/libpakfire/db.c new file mode 100644 index 00000000..e0c324e5 --- /dev/null +++ b/tests/libpakfire/db.c @@ -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 . # +# # +#############################################################################*/ + +#include +#include + +#include "../testsuite.h" + +static int test_open_ro(const struct test* t) { + struct pakfire_db* db; + + int r = pakfire_db_open(&db, t->pakfire, PAKFIRE_DB_READONLY); + ASSERT(!r); + + pakfire_db_unref(db); + + return 0; +} + +static int test_open_rw(const struct test* t) { + struct pakfire_db* db; + + int r = pakfire_db_open(&db, t->pakfire, PAKFIRE_DB_READWRITE); + ASSERT(!r); + + pakfire_db_unref(db); + + return 0; +} + +int main(int argc, char** argv) { + testsuite_add_test(test_open_ro); + testsuite_add_test(test_open_rw); + + return testsuite_run(); +}