-
Notifications
You must be signed in to change notification settings - Fork 53
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
Copy Python tests for Modulemd.ModuleStream.tracker into C #410
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
#define MMD_TEST_DOC_UNICODE_TEXT \ | ||
"À϶¥🌭∮⇒⇔¬β∀₂⌀ıəˈ⍳⍴V)" \ | ||
"═€ίζησθლბშიнстемองจึองታሽ።ደለᚢᛞᚦᚹ⠳⠞⠊⠎▉▒▒▓😃" | ||
#define MMD_TEST_TRACKER_PROP "tracker" | ||
|
||
typedef struct _ModuleStreamFixture | ||
{ | ||
|
@@ -477,6 +478,136 @@ module_stream_v2_test_documentation (ModuleStreamFixture *fixture, | |
g_clear_object (&stream); | ||
} | ||
|
||
static void | ||
module_stream_v1_test_tracker (ModuleStreamFixture *fixture, | ||
gconstpointer user_data) | ||
{ | ||
g_autoptr (ModulemdModuleStreamV1) stream = NULL; | ||
g_autofree gchar *tracker_prop = NULL; | ||
const gchar *tracker = NULL; | ||
|
||
stream = modulemd_module_stream_v1_new (NULL, NULL); | ||
|
||
// Check the defaults | ||
g_object_get (stream, MMD_TEST_TRACKER_PROP, &tracker_prop, NULL); | ||
tracker = modulemd_module_stream_v1_get_tracker (stream); | ||
|
||
g_assert_null (tracker); | ||
g_assert_null (tracker_prop); | ||
|
||
g_clear_pointer (&tracker_prop, g_free); | ||
|
||
// Test property setting | ||
g_object_set (stream, MMD_TEST_TRACKER_PROP, MMD_TEST_DOC_TEXT, NULL); | ||
|
||
g_object_get (stream, MMD_TEST_TRACKER_PROP, &tracker_prop, NULL); | ||
tracker = modulemd_module_stream_v1_get_tracker (stream); | ||
|
||
g_assert_cmpstr (tracker, ==, MMD_TEST_DOC_TEXT); | ||
g_assert_cmpstr (tracker_prop, ==, MMD_TEST_DOC_TEXT); | ||
|
||
g_clear_pointer (&tracker_prop, g_free); | ||
|
||
// Test set_tracker | ||
modulemd_module_stream_v1_set_tracker (stream, MMD_TEST_DOC_TEXT2); | ||
|
||
g_object_get (stream, MMD_TEST_TRACKER_PROP, &tracker_prop, NULL); | ||
tracker = modulemd_module_stream_v1_get_tracker (stream); | ||
|
||
g_assert_cmpstr (tracker, ==, MMD_TEST_DOC_TEXT2); | ||
g_assert_cmpstr (tracker_prop, ==, MMD_TEST_DOC_TEXT2); | ||
|
||
g_clear_pointer (&tracker_prop, g_free); | ||
|
||
// Test setting it to NULL | ||
g_object_set (stream, MMD_TEST_TRACKER_PROP, NULL, NULL); | ||
|
||
g_object_get (stream, MMD_TEST_TRACKER_PROP, &tracker_prop, NULL); | ||
tracker = modulemd_module_stream_v1_get_tracker (stream); | ||
|
||
g_assert_null (tracker); | ||
g_assert_null (tracker_prop); | ||
|
||
g_clear_pointer (&tracker_prop, g_free); | ||
|
||
// Test Unicode values | ||
modulemd_module_stream_v1_set_tracker (stream, MMD_TEST_DOC_UNICODE_TEXT); | ||
|
||
g_object_get (stream, MMD_TEST_TRACKER_PROP, &tracker_prop, NULL); | ||
tracker = modulemd_module_stream_v1_get_tracker (stream); | ||
|
||
g_assert_cmpstr (tracker, ==, MMD_TEST_DOC_UNICODE_TEXT); | ||
g_assert_cmpstr (tracker_prop, ==, MMD_TEST_DOC_UNICODE_TEXT); | ||
|
||
g_clear_pointer (&tracker_prop, g_free); | ||
g_clear_object (&stream); | ||
} | ||
|
||
static void | ||
module_stream_v2_test_tracker (ModuleStreamFixture *fixture, | ||
gconstpointer user_data) | ||
{ | ||
g_autoptr (ModulemdModuleStreamV2) stream = NULL; | ||
g_autofree gchar *tracker_prop = NULL; | ||
const gchar *tracker = NULL; | ||
|
||
stream = modulemd_module_stream_v2_new (NULL, NULL); | ||
|
||
// Check the defaults | ||
g_object_get (stream, MMD_TEST_TRACKER_PROP, &tracker_prop, NULL); | ||
tracker = modulemd_module_stream_v2_get_tracker (stream); | ||
|
||
g_assert_null (tracker); | ||
g_assert_null (tracker_prop); | ||
|
||
g_clear_pointer (&tracker_prop, g_free); | ||
|
||
// Test property setting | ||
g_object_set (stream, MMD_TEST_TRACKER_PROP, MMD_TEST_DOC_TEXT, NULL); | ||
|
||
g_object_get (stream, MMD_TEST_TRACKER_PROP, &tracker_prop, NULL); | ||
tracker = modulemd_module_stream_v2_get_tracker (stream); | ||
|
||
g_assert_cmpstr (tracker, ==, MMD_TEST_DOC_TEXT); | ||
g_assert_cmpstr (tracker_prop, ==, MMD_TEST_DOC_TEXT); | ||
|
||
g_clear_pointer (&tracker_prop, g_free); | ||
|
||
// Test set_tracker | ||
modulemd_module_stream_v2_set_tracker (stream, MMD_TEST_DOC_TEXT2); | ||
|
||
g_object_get (stream, MMD_TEST_TRACKER_PROP, &tracker_prop, NULL); | ||
tracker = modulemd_module_stream_v2_get_tracker (stream); | ||
|
||
g_assert_cmpstr (tracker, ==, MMD_TEST_DOC_TEXT2); | ||
g_assert_cmpstr (tracker_prop, ==, MMD_TEST_DOC_TEXT2); | ||
|
||
g_clear_pointer (&tracker_prop, g_free); | ||
|
||
// Test setting it to NULL | ||
g_object_set (stream, MMD_TEST_TRACKER_PROP, NULL, NULL); | ||
|
||
g_object_get (stream, MMD_TEST_TRACKER_PROP, &tracker_prop, NULL); | ||
tracker = modulemd_module_stream_v2_get_tracker (stream); | ||
|
||
g_assert_null (tracker); | ||
g_assert_null (tracker_prop); | ||
|
||
g_clear_pointer (&tracker_prop, g_free); | ||
|
||
// Test Unicode values | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. |
||
modulemd_module_stream_v2_set_tracker (stream, MMD_TEST_DOC_UNICODE_TEXT); | ||
|
||
g_object_get (stream, MMD_TEST_TRACKER_PROP, &tracker_prop, NULL); | ||
tracker = modulemd_module_stream_v2_get_tracker (stream); | ||
|
||
g_assert_cmpstr (tracker, ==, MMD_TEST_DOC_UNICODE_TEXT); | ||
g_assert_cmpstr (tracker_prop, ==, MMD_TEST_DOC_UNICODE_TEXT); | ||
|
||
g_clear_pointer (&tracker_prop, g_free); | ||
g_clear_object (&stream); | ||
} | ||
|
||
static void | ||
module_stream_v1_test_components (ModuleStreamFixture *fixture, | ||
gconstpointer user_data) | ||
|
@@ -2165,6 +2296,20 @@ main (int argc, char *argv[]) | |
module_stream_v2_test_licenses, | ||
NULL); | ||
|
||
g_test_add ("/modulemd/v2/modulestream/v1/tracker", | ||
ModuleStreamFixture, | ||
NULL, | ||
NULL, | ||
module_stream_v1_test_tracker, | ||
NULL); | ||
|
||
g_test_add ("/modulemd/v2/modulestream/v2/tracker", | ||
ModuleStreamFixture, | ||
NULL, | ||
NULL, | ||
module_stream_v2_test_tracker, | ||
NULL); | ||
|
||
g_test_add ("/modulemd/v2/modulestream/v1/profiles", | ||
ModuleStreamFixture, | ||
NULL, | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the docs, the
tracker
is:The website address of the upstream bug tracker for this module.
So it doesn't really make sense to have Unicode characters in a website URL. Now we should either remove this test assuming no one is ever going to add a URL containing Unicode or handle this case in the main function by returning
NULL
whenever we encounter an invalid URL.@sgallagher What do you suggest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave it as-is for now. There's nothing stopping someone right now from putting unicode into the metadata here. We should probably look at using http-parser or llhttp to validate that we have validly-formatted URLs though. Mind opening a ticket to track that?