Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extends tests for ModuleStream.depends_on_stream() #203

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions modulemd/v2/tests/ModulemdTests/modulestream.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,6 @@ def test_v2_yaml(self):

assert 'rawhide' in stream.get_servicelevel_names()
assert 'production' in stream.get_servicelevel_names()

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why delete this line?

sl = stream.get_servicelevel('rawhide')
assert sl is not None
assert sl.props.name == 'rawhide'
Expand Down Expand Up @@ -1035,8 +1034,16 @@ def test_depends_on_stream(self):
stream.build_depends_on_stream(
'platform', 'f28'), False)

self.assertEqual(stream.depends_on_stream('base', 'f30'), False)
self.assertEqual(stream.depends_on_stream('base', 'f30'), False)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you removing these two tests? Though, the second one should have been stream.build_depends_on_stream(), That's a bug in the original code here.

self.assertEqual(
stream.depends_on_stream(
'base', ''), False)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you misunderstood the requirement here. We don't need tests for a stream name being the empty string. We need a new requires/buildrequires in the v2 YAML document. Something like perl in:

  dependencies:
  - buildrequires:
      platform: [ f30 ]
      perl: []
    requires:
      platform: [ -f28 ]
      perl: []

This test is ONLY for ModuleStreamV2, since there is no way to represent this in the ModuleStreamV1 YAML.

self.assertEqual(
stream.build_depends_on_stream(
'base', ''), False)

ret = stream.build_depends_on_stream(
'platform', '')
assert (ret is True or ret is False)


if __name__ == '__main__':
Expand Down
159 changes: 159 additions & 0 deletions modulemd/v2/tests/test-modulemd-modulestream.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,152 @@ module_stream_test_copy (ModuleStreamFixture *fixture, gconstpointer user_data)
}
}

static void
module_stream_v1_test_depends_on_stream (ModuleStreamFixture *fixture,
gconstpointer user_data)
{
g_autoptr (ModulemdModuleStream) stream = NULL;
g_autofree gchar *path = NULL;
g_autoptr (GError) error = NULL;
g_autofree gchar *module_name = NULL;
g_autofree gchar *module_stream = NULL;
gboolean ret;

path = g_strdup_printf ("%s/modulemd/v2/tests/test_data/dependson_v1.yaml",
g_getenv ("MESON_SOURCE_ROOT"));
g_assert_nonnull (path);
stream = modulemd_module_stream_read_file (
path, TRUE, module_name, module_stream, &error);
g_assert_nonnull (stream);
g_assert_true (
modulemd_module_stream_depends_on_stream (stream, "platform", "f30"));
g_clear_object (&stream);

stream = modulemd_module_stream_read_file (
path, TRUE, module_name, module_stream, &error);
g_assert_nonnull (stream);
g_assert_true (modulemd_module_stream_build_depends_on_stream (
stream, "platform", "f30"));
g_clear_object (&stream);

stream = modulemd_module_stream_read_file (
path, TRUE, module_name, module_stream, &error);
g_assert_nonnull (stream);
g_assert_false (
modulemd_module_stream_depends_on_stream (stream, "platform", "f28"));
g_clear_object (&stream);

stream = modulemd_module_stream_read_file (
path, TRUE, module_name, module_stream, &error);
g_assert_nonnull (stream);
g_assert_false (modulemd_module_stream_build_depends_on_stream (
stream, "platform", "f28"));
g_clear_object (&stream);

stream = modulemd_module_stream_read_file (
path, TRUE, module_name, module_stream, &error);
g_assert_nonnull (stream);
g_assert_false (
modulemd_module_stream_depends_on_stream (stream, "base", "f30"));
g_clear_object (&stream);

stream = modulemd_module_stream_read_file (
path, TRUE, module_name, module_stream, &error);
g_assert_nonnull (stream);
g_assert_false (
modulemd_module_stream_build_depends_on_stream (stream, "base", "f30"));
g_clear_object (&stream);

stream = modulemd_module_stream_read_file (
path, TRUE, module_name, module_stream, &error);
g_assert_nonnull (stream);
ret = modulemd_module_stream_depends_on_stream (stream, "platform", "");
g_assert (ret == 0 || ret == 1);
g_clear_object (&stream);

stream = modulemd_module_stream_read_file (
path, TRUE, module_name, module_stream, &error);
g_assert_nonnull (stream);
ret =
modulemd_module_stream_build_depends_on_stream (stream, "platform", "");
g_assert (ret == 0 || ret == 1);
g_clear_object (&stream);
}

static void
module_stream_v2_test_depends_on_stream (ModuleStreamFixture *fixture,
gconstpointer user_data)
{
g_autoptr (ModulemdModuleStream) stream = NULL;
g_autofree gchar *path = NULL;
g_autoptr (GError) error = NULL;
g_autofree gchar *module_name = NULL;
g_autofree gchar *module_stream = NULL;
gboolean ret;


path = g_strdup_printf ("%s/modulemd/v2/tests/test_data/dependson_v2.yaml",
g_getenv ("MESON_SOURCE_ROOT"));
g_assert_nonnull (path);
stream = modulemd_module_stream_read_file (
path, TRUE, module_name, module_stream, &error);
g_assert_nonnull (stream);
g_assert_true (
modulemd_module_stream_depends_on_stream (stream, "platform", "f30"));
g_clear_object (&stream);

stream = modulemd_module_stream_read_file (
path, TRUE, module_name, module_stream, &error);
g_assert_nonnull (stream);
g_assert_true (modulemd_module_stream_build_depends_on_stream (
stream, "platform", "f30"));
g_clear_object (&stream);

stream = modulemd_module_stream_read_file (
path, TRUE, module_name, module_stream, &error);
g_assert_nonnull (stream);
g_assert_false (
modulemd_module_stream_depends_on_stream (stream, "platform", "f28"));
g_clear_object (&stream);

stream = modulemd_module_stream_read_file (
path, TRUE, module_name, module_stream, &error);
g_assert_nonnull (stream);
g_assert_false (modulemd_module_stream_build_depends_on_stream (
stream, "platform", "f28"));
g_clear_object (&stream);

stream = modulemd_module_stream_read_file (
path, TRUE, module_name, module_stream, &error);
g_assert_nonnull (stream);
g_assert_false (
modulemd_module_stream_depends_on_stream (stream, "base", "f30"));
g_clear_object (&stream);

stream = modulemd_module_stream_read_file (
path, TRUE, module_name, module_stream, &error);
g_assert_nonnull (stream);
g_assert_false (
modulemd_module_stream_build_depends_on_stream (stream, "base", "f30"));
g_clear_object (&stream);

stream = modulemd_module_stream_read_file (
path, TRUE, module_name, module_stream, &error);
g_assert_nonnull (stream);
ret = modulemd_module_stream_depends_on_stream (stream, "platform", "");
g_assert (ret == 0 || ret == 1);
g_clear_object (&stream);

stream = modulemd_module_stream_read_file (
path, TRUE, module_name, module_stream, &error);
g_assert_nonnull (stream);
ret =
modulemd_module_stream_build_depends_on_stream (stream, "platform", "");
g_assert (ret == 0 || ret == 1);
g_clear_object (&stream);
}


static void
module_stream_v1_test_parse_dump (ModuleStreamFixture *fixture,
gconstpointer user_data)
Expand Down Expand Up @@ -525,6 +671,19 @@ main (int argc, char *argv[])
NULL,
module_stream_test_copy,
NULL);
g_test_add ("/modulemd/v2/modulestream/v1/depends_on_stream",
ModuleStreamFixture,
NULL,
NULL,
module_stream_v1_test_depends_on_stream,
NULL);
g_test_add ("/modulemd/v2/modulestream/v2/depends_on_stream",
ModuleStreamFixture,
NULL,
NULL,
module_stream_v2_test_depends_on_stream,
NULL);


g_test_add ("/modulemd/v2/modulestream/v1/parse_dump",
ModuleStreamFixture,
Expand Down