From b873aca640964389935d88a90a657abba89421e3 Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Thu, 6 Sep 2018 11:17:41 -0400 Subject: [PATCH 1/2] Properly write out the ref for module components Fixes: https://github.com/fedora-modularity/libmodulemd/issues/85 Signed-off-by: Stephen Gallagher --- modulemd/v1/modulemd-yaml-emitter-modulemd.c | 2 +- modulemd/v1/tests/test-modulemd-python.py | 50 +++++++++++++++++++ modulemd/v1/tests/test-modulemd-translation.c | 2 +- 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/modulemd/v1/modulemd-yaml-emitter-modulemd.c b/modulemd/v1/modulemd-yaml-emitter-modulemd.c index 87093813e28f5dd42ab014265874ce2148372c8a..7b0fbfafe1cdb4651f2f9b7147f9c082eb76ee2a 100644 --- a/modulemd/v1/modulemd-yaml-emitter-modulemd.c +++ b/modulemd/v1/modulemd-yaml-emitter-modulemd.c @@ -1353,11 +1353,11 @@ _emit_modulemd_module_components (yaml_emitter_t *emitter, MMD_YAML_EMIT_STR_STR_DICT ( &event, name, value, YAML_PLAIN_SCALAR_STYLE); } /* Ref */ - value = modulemd_component_module_dup_repository (module_component); + value = modulemd_component_module_dup_ref (module_component); if (value) { name = g_strdup ("ref"); MMD_YAML_EMIT_STR_STR_DICT ( &event, name, value, YAML_PLAIN_SCALAR_STYLE); diff --git a/modulemd/v1/tests/test-modulemd-python.py b/modulemd/v1/tests/test-modulemd-python.py index 07823213de9c7f16e16719efe0eccf155117cfa5..596665a6df2e367d0817c08b0bfc651cecd14e6a 100755 --- a/modulemd/v1/tests/test-modulemd-python.py +++ b/modulemd/v1/tests/test-modulemd-python.py @@ -214,10 +214,60 @@ class TestIssues(unittest.TestCase): yaml_output = mmd_translation.dumps() except GLib.GError as err: # A proper exception is expected here pass + def test_issue85(self): + """ + Component module refs are lost when dumping to YAML + """ + mmd = Modulemd.Module().new_from_string(""" +document: modulemd +version: 1 +data: + summary: A test module in all its beautiful beauty. + description: This module demonstrates how to write simple modulemd files And can be used for testing the build and release pipeline. + license: + module: [ MIT ] + dependencies: + buildrequires: + platform: el8 + requires: + platform: el8 + references: + community: https://fedoraproject.org/wiki/Modularity + documentation: https://fedoraproject.org/wiki/Fedora_Packaging_Guidelines_for_Modules + tracker: https://taiga.fedorainfracloud.org/project/modularity + profiles: + default: + rpms: + - acl + api: + rpms: + - acl + components: + rpms: + acl: + rationale: needed + ref: rhel-8.0 + modules: + testmodule: + ref: private-x + rationale: Testing module inclusion. + buildorder: 10 +""") + assert mmd.get_module_components( + )['testmodule'].peek_ref() == 'private-x' + + mmd2 = Modulemd.Module.copy(mmd) + assert mmd2.get_module_components( + )['testmodule'].peek_ref() == 'private-x' + + mmd3 = Modulemd.Module.new_from_string(mmd.dumps()) + assert mmd3.get_module_components( + )['testmodule'].peek_ref() == 'private-x' + class TestIntent(unittest.TestCase): def test_basic(self): intent = Modulemd.Intent.new("intent_name") diff --git a/modulemd/v1/tests/test-modulemd-translation.c b/modulemd/v1/tests/test-modulemd-translation.c index a85ba5131db562aa9be3255fae3db13e9ee66508..dfa07f48d5ada811a5c82f14e7bcf52c7b258b94 100644 --- a/modulemd/v1/tests/test-modulemd-translation.c +++ b/modulemd/v1/tests/test-modulemd-translation.c @@ -350,11 +350,11 @@ modulemd_translation_test_index (TranslationFixture *fixture, "demonstrates arches and multilib.\n arches: [i686, x86_64]\n " " multilib: [x86_64]\n xyz:\n rationale: xyz is a bundled " "dependency of xxx.\n buildorder: 10\n modules:\n " "includedmodule:\n rationale: Included in the stack, just " "because.\n repository: https://pagure.io/includedmodule.git\n " - " ref: https://pagure.io/includedmodule.git\n buildorder: 100\n " + " ref: somecoolbranchname\n buildorder: 100\n " "artifacts:\n rpms:\n - bar-0:1.23-1.module_deadbeef.x86_64\n - " "bar-devel-0:1.23-1.module_deadbeef.x86_64\n - " "bar-extras-0:1.23-1.module_deadbeef.x86_64\n - " "baz-0:42-42.module_deadbeef.x86_64\n - " "xxx-0:1-1.module_deadbeef.i686\n - xxx-0:1-1.module_deadbeef.x86_64\n " -- 2.19.0.rc0