diff options
author | Fabiano FidĂȘncio <fidencio@redhat.com> | 2019-04-29 10:44:05 +0200 |
---|---|---|
committer | Fabiano FidĂȘncio <fidencio@redhat.com> | 2019-05-02 09:08:35 +0200 |
commit | 7f0cc3f3522b297c0d6333d885aefd99c8d2aa32 (patch) | |
tree | 198d3bf85f345173a3fce4d4fc485272c0ec7e2b | |
parent | d430b3cc99a458527f047b5c01a83f2f83ee1a16 (diff) | |
download | libosinfo-7f0cc3f3522b297c0d6333d885aefd99c8d2aa32.tar.gz |
tests: Add tests for multiple short-ids
I've decided to for testing the multiple short-ids at the os level, as
it reflects better the usage of the newly added APIs.
https://gitlab.com/libosinfo/libosinfo/issues/19
Signed-off-by: Fabiano FidĂȘncio <fidencio@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
-rw-r--r-- | tests/dbdata/os/libosinfo.org/test-os-multipleshortids.xml | 13 | ||||
-rw-r--r-- | tests/test-os.c | 32 |
2 files changed, 45 insertions, 0 deletions
diff --git a/tests/dbdata/os/libosinfo.org/test-os-multipleshortids.xml b/tests/dbdata/os/libosinfo.org/test-os-multipleshortids.xml new file mode 100644 index 0000000..ccc2b54 --- /dev/null +++ b/tests/dbdata/os/libosinfo.org/test-os-multipleshortids.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<libosinfo version="0.0.1"> + <os id="http://libosinfo.org/test/os/multipleshortids"> + <short-id>shortid0</short-id> + <short-id>shortid1</short-id> + <short-id>shortid2</short-id> + <name>Multiple Short Ids</name> + <version>unknown</version> + <vendor>libosinfo.org</vendor> + <family>test</family> + <release-status>prerelease</release-status> + </os> +</libosinfo> diff --git a/tests/test-os.c b/tests/test-os.c index b8b0a16..fe7c2d6 100644 --- a/tests/test-os.c +++ b/tests/test-os.c @@ -619,6 +619,37 @@ test_find_install_script(void) g_object_unref(os); } +static void +test_multiple_short_ids(void) +{ + OsinfoLoader *loader = osinfo_loader_new(); + OsinfoDb *db; + OsinfoOs *os; + GList *shortid_list, *l; + GError *error = NULL; + const gchar *shortid; + const gchar *expected_short_id_list[] = {"shortid0", "shortid1", "shortid2"}; + gsize i; + + osinfo_loader_process_path(loader, SRCDIR "/tests/dbdata", &error); + g_assert_no_error(error); + db = g_object_ref(osinfo_loader_get_db(loader)); + g_object_unref(loader); + + os = osinfo_db_get_os(db, "http://libosinfo.org/test/os/multipleshortids"); + g_assert(OSINFO_IS_OS(os)); + + shortid = osinfo_product_get_short_id(OSINFO_PRODUCT(os)); + g_assert_cmpstr(shortid, ==, expected_short_id_list[0]); + + shortid_list = osinfo_product_get_short_id_list(OSINFO_PRODUCT(os)); + for (l = shortid_list, i = 0; l != NULL; l = l->next, i++) { + g_assert_cmpstr(l->data, ==, expected_short_id_list[i]); + } + g_list_free(shortid_list); + + g_object_unref(db); +} int main(int argc, char *argv[]) @@ -638,6 +669,7 @@ main(int argc, char *argv[]) g_test_add_func("/os/resources/basic", test_resources_basic); g_test_add_func("/os/resources/inheritance", test_resources_inheritance); g_test_add_func("/os/find_install_script", test_find_install_script); + g_test_add_func("/os/mulitple_short_ids", test_multiple_short_ids); /* Upfront so we don't confuse valgrind */ osinfo_platform_get_type(); |