[libosinfo PATCH 3/3] test-media: Add test for media installer script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx>
---
 .../test-os-media-installer-script.xml        | 16 ++++++++++
 tests/test-media.c                            | 32 +++++++++++++++++++
 2 files changed, 48 insertions(+)
 create mode 100644 tests/dbdata/os/libosinfo.org/test-os-media-installer-script.xml

diff --git a/tests/dbdata/os/libosinfo.org/test-os-media-installer-script.xml b/tests/dbdata/os/libosinfo.org/test-os-media-installer-script.xml
new file mode 100644
index 0000000..f6422ee
--- /dev/null
+++ b/tests/dbdata/os/libosinfo.org/test-os-media-installer-script.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<libosinfo version="0.0.1">
+  <os id="http://libosinfo.org/test/os/media-installer-script";>
+    <short-id>media-no-installer</short-id>
+    <name>Media no installer</name>
+    <version>unknown</version>
+    <vendor>libosinfo.org</vendor>
+    <family>test</family>
+
+    <media arch="x86_64">
+      <installer>
+        <script id="http://example.com/libosinfo/test-install-script"/>
+      </installer>
+    </media>
+  </os>
+</libosinfo>
diff --git a/tests/test-media.c b/tests/test-media.c
index bfa053f..e8bd702 100644
--- a/tests/test-media.c
+++ b/tests/test-media.c
@@ -110,6 +110,37 @@ test_loaded_no_installer(void)
     g_object_unref(loader);
 }
 
+static void
+test_loaded_installer_script(void)
+{
+
+    OsinfoLoader *loader = osinfo_loader_new();
+    OsinfoDb *db;
+    OsinfoOs *os;
+    OsinfoMedia *media;
+    OsinfoMediaList *list;
+    OsinfoInstallScriptList *scripts;
+    gint list_len;
+    GError *error = NULL;
+
+    osinfo_loader_process_path(loader, SRCDIR "/tests/dbdata", &error);
+    g_assert_no_error(error);
+    db = osinfo_loader_get_db(loader);
+
+    os = osinfo_db_get_os(db, "http://libosinfo.org/test/os/media-installer-script";);
+
+    list = osinfo_os_get_media_list(os);
+    list_len = osinfo_list_get_length(OSINFO_LIST(list));
+    g_assert_cmpint(list_len, ==, 1);
+
+    media = OSINFO_MEDIA(osinfo_list_get_nth(OSINFO_LIST(list), 0));
+    scripts = osinfo_media_get_install_script_list(media);
+    g_assert_cmpint(osinfo_list_get_length(OSINFO_LIST(scripts)), ==, 1);
+
+    g_object_unref(scripts);
+    g_object_unref(list);
+    g_object_unref(loader);
+}
 
 int
 main(int argc, char *argv[])
@@ -119,6 +150,7 @@ main(int argc, char *argv[])
     g_test_add_func("/media/basic", test_basic);
     g_test_add_func("/media/loaded/attributes", test_loaded_attributes);
     g_test_add_func("/media/loaded/no-installer", test_loaded_no_installer);
+    g_test_add_func("/media/loaded/installer-script", test_loaded_installer_script);
 
     /* Upfront so we don't confuse valgrind */
     osinfo_media_get_type();
-- 
2.20.1

_______________________________________________
Libosinfo mailing list
Libosinfo@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libosinfo




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux