libmpm

morphux C package management library
Log | Files | Refs | Submodules | README | LICENSE | git clone https://git.ne02ptzero.me/git/libmpm

commit 0f48b528781ff0f231427928cc8a49f8cc1ddb1c
parent 1fa62a5aa0878754226592aba39fc7313ccab889
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Fri, 10 Feb 2017 19:11:32 +0100

Merge branch 'unstable'

Diffstat:
Mtests/test_database.c | 53+++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+), 0 deletions(-)

diff --git a/tests/test_database.c b/tests/test_database.c @@ -366,6 +366,23 @@ TEST(database_get_pkg_by_id_2) { return TEST_SUCCESS; } +TEST(database_get_pkg_by_id_3) { + mlist_t *lst; + database_t *ptr = NULL; + u8_t ret = 0; + + ptr = mpm_database_open(&ret, NULL); + TEST_ASSERT((ret == 0), "Can't open the database"); + TEST_ASSERT((ptr != NULL), "Can't open the database"); + + ret = mpm_get_package_by_id(ptr, 100, &lst); + TEST_ASSERT((list_size(lst) == 0), "Found the package ?!"); + mpm_database_close(ptr); + list_free(lst, &mpm_package_free); + return TEST_SUCCESS; +} + + TEST(database_get_category_by_name_1) { mlist_t *lst; database_t *ptr = NULL; @@ -433,6 +450,22 @@ TEST(database_get_pkg_by_name_2) { return TEST_SUCCESS; } +TEST(database_get_pkg_by_name_3) { + mlist_t *lst; + database_t *ptr = NULL; + u8_t ret = 0; + + ptr = mpm_database_open(&ret, NULL); + TEST_ASSERT((ret == 0), "Can't open the database"); + TEST_ASSERT((ptr != NULL), "Can't open the database"); + + ret = mpm_get_package_by_name(ptr, "nonsense", &lst); + TEST_ASSERT((list_size(lst) == 0), "Found the package ?!"); + mpm_database_close(ptr); + list_free(lst, &mpm_package_free); + return TEST_SUCCESS; +} + TEST(database_sql_to_package) { package_t *ptr = NULL; @@ -633,6 +666,23 @@ TEST(database_get_category_by_id_2) { return TEST_SUCCESS; } +TEST(database_get_category_by_id_3) { + mlist_t *lst; + database_t *ptr = NULL; + u8_t ret = 0; + + ptr = mpm_database_open(&ret, NULL); + TEST_ASSERT((ret == 0), "Can't open the database"); + TEST_ASSERT((ptr != NULL), "Can't open the database"); + + ret = mpm_get_categ_by_id(ptr, 100, &lst); + TEST_ASSERT((list_size(lst) == 0), "Found the package ?!"); + mpm_database_close(ptr); + list_free(lst, &mpm_category_free); + return TEST_SUCCESS; +} + + TEST(database_sql_to_file) { file_t *ptr = NULL; int st, fd[2]; @@ -743,8 +793,10 @@ void register_test_database(void) { reg_test("database", database_add_pkg_2); reg_test("database", database_get_pkg_by_id_1); reg_test("database", database_get_pkg_by_id_2); + reg_test("database", database_get_pkg_by_id_3); reg_test("database", database_get_pkg_by_name_1); reg_test("database", database_get_pkg_by_name_2); + reg_test("database", database_get_pkg_by_name_3); reg_test("database", database_sql_to_package); reg_test("database", database_add_file_1); reg_test("database", database_add_file_2); @@ -765,6 +817,7 @@ void register_test_database(void) { reg_test("database", database_add_category_2); reg_test("database", database_get_category_by_id_1); reg_test("database", database_get_category_by_id_2); + reg_test("database", database_get_category_by_id_3); reg_test("database", database_get_category_by_name_1); reg_test("database", database_get_category_by_name_2); reg_test("database", database_get_category_by_name_3);