diff --git a/modulemd/tests/test-modulemd-modulestream.c b/modulemd/tests/test-modulemd-modulestream.c index 9eebed777..00303d66a 100644 --- a/modulemd/tests/test-modulemd-modulestream.c +++ b/modulemd/tests/test-modulemd-modulestream.c @@ -23,10 +23,6 @@ "═€ίζησθლბშიнстемองจึองታሽ።ደለᚢᛞᚦᚹ⠳⠞⠊⠎▉▒▒▓😃" #define MMD_TEST_TRACKER_PROP "tracker" -typedef struct _ModuleStreamFixture -{ -} ModuleStreamFixture; - static void module_stream_test_construct (void) @@ -524,6 +520,83 @@ module_stream_v2_test_rpm_artifacts (void) g_clear_object (&stream); } + +static void +module_stream_v1_test_servicelevels (void) +{ + g_autoptr (ModulemdModuleStreamV1) stream = NULL; + g_auto (GStrv) servicelevel_names = NULL; + g_autoptr (ModulemdServiceLevel) sl = NULL; + ModulemdServiceLevel *sl_retrieved = NULL; + g_autofree gchar *name_prop = NULL; + g_autofree gchar *eol_str = NULL; + + stream = modulemd_module_stream_v1_new (NULL, NULL); + sl = modulemd_service_level_new ("rawhide"); + modulemd_service_level_set_eol_ymd (sl, 1980, 3, 2); + + modulemd_module_stream_v1_add_servicelevel (stream, sl); + + servicelevel_names = + modulemd_module_stream_v1_get_servicelevel_names_as_strv (stream); + g_assert_true ( + g_strv_contains ((const gchar *const *)servicelevel_names, "rawhide")); + g_assert_cmpint (g_strv_length (servicelevel_names), ==, 1); + + sl_retrieved = + modulemd_module_stream_v1_get_servicelevel (stream, "rawhide"); + g_object_get (sl_retrieved, "name", &name_prop, NULL); + eol_str = modulemd_service_level_get_eol_as_string (sl_retrieved); + + g_assert_cmpstr (name_prop, ==, "rawhide"); + g_assert_cmpstr (eol_str, ==, "1980-03-02"); + + g_clear_object (&sl); + g_clear_object (&stream); + g_clear_pointer (&name_prop, g_free); + g_clear_pointer (&eol_str, g_free); + g_clear_pointer (&servicelevel_names, g_strfreev); +} + + +static void +module_stream_v2_test_servicelevels (void) +{ + g_autoptr (ModulemdModuleStreamV2) stream = NULL; + g_auto (GStrv) servicelevel_names = NULL; + g_autoptr (ModulemdServiceLevel) sl = NULL; + ModulemdServiceLevel *sl_retrieved = NULL; + g_autofree gchar *name_prop = NULL; + g_autofree gchar *eol_str = NULL; + + stream = modulemd_module_stream_v2_new (NULL, NULL); + sl = modulemd_service_level_new ("rawhide"); + modulemd_service_level_set_eol_ymd (sl, 1980, 3, 2); + + modulemd_module_stream_v2_add_servicelevel (stream, sl); + + servicelevel_names = + modulemd_module_stream_v2_get_servicelevel_names_as_strv (stream); + g_assert_true ( + g_strv_contains ((const gchar *const *)servicelevel_names, "rawhide")); + g_assert_cmpint (g_strv_length (servicelevel_names), ==, 1); + + sl_retrieved = + modulemd_module_stream_v2_get_servicelevel (stream, "rawhide"); + g_object_get (sl_retrieved, "name", &name_prop, NULL); + eol_str = modulemd_service_level_get_eol_as_string (sl_retrieved); + + g_assert_cmpstr (name_prop, ==, "rawhide"); + g_assert_cmpstr (eol_str, ==, "1980-03-02"); + + g_clear_object (&sl); + g_clear_object (&stream); + g_clear_pointer (&name_prop, g_free); + g_clear_pointer (&eol_str, g_free); + g_clear_pointer (&servicelevel_names, g_strfreev); +} + + static void module_stream_v1_test_documentation (void) { @@ -2547,13 +2620,18 @@ main (int argc, char *argv[]) g_test_add_func ("/modulemd/v2/modulestream/upgrade", module_stream_test_upgrade); - g_test_add_func ("/modulemd/v2/modulestream/v1/rpm_artifacts", module_stream_v1_test_rpm_artifacts); g_test_add_func ("/modulemd/v2/modulestream/v2/rpm_artifacts", module_stream_v2_test_rpm_artifacts); + g_test_add_func ("/modulemd/v2/modulestream/v1/servicelevels", + module_stream_v2_test_servicelevels); + + g_test_add_func ("/modulemd/v2/modulestream/v2/servicelevels", + module_stream_v1_test_servicelevels); + g_test_add_func ("/modulemd/v2/modulestream/v1/components", module_stream_v1_test_components);