-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
ref(stacktrace-link): Minor refactor #101154
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
Merged
+12
−22
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 hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
---|---|---|
|
@@ -124,21 +124,7 @@ def expected_configurations( | |
|
||
|
||
class ProjectStacktraceLinkTest(BaseProjectStacktraceLink): | ||
endpoint = "sentry-api-0-project-stacktrace-link" | ||
|
||
def setUp(self) -> None: | ||
BaseProjectStacktraceLink.setUp(self) | ||
self.code_mapping1 = self._create_code_mapping( | ||
stack_root="usr/src/getsentry/", | ||
source_root="", | ||
) | ||
self.code_mapping2 = self._create_code_mapping( | ||
stack_root="sentry/", | ||
source_root="src/sentry/", | ||
automatically_generated=True, # Created by the automation | ||
) | ||
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. We will let each test decide what code mappings makes sense to create rather than create it for each test. |
||
|
||
self.filepath = "usr/src/getsentry/src/sentry/src/sentry/utils/safe.py" | ||
filepath = "usr/src/getsentry/src/sentry/src/sentry/utils/safe.py" | ||
|
||
def test_no_filepath(self) -> None: | ||
"""The file query search is missing""" | ||
|
@@ -168,10 +154,11 @@ def test_no_configs(self) -> None: | |
|
||
def test_file_not_found_error(self) -> None: | ||
"""File matches code mapping but it cannot be found in the source repository.""" | ||
cm = self._create_code_mapping(stack_root="usr/src/getsentry/", source_root="") | ||
response = self.get_success_response( | ||
self.organization.slug, self.project.slug, qs_params={"file": self.filepath} | ||
) | ||
assert response.data["config"] == self.expected_configurations(self.code_mapping1) | ||
assert response.data["config"] == self.expected_configurations(cm) | ||
assert not response.data["sourceUrl"] | ||
assert response.data["error"] == "file_not_found" | ||
assert response.data["integrations"] == [serialized_integration(self.integration)] | ||
|
@@ -182,6 +169,8 @@ def test_file_not_found_error(self) -> None: | |
|
||
def test_stack_root_mismatch_error(self) -> None: | ||
"""Looking for a stacktrace file path that will not match any code mappings""" | ||
# At least one code mapping to produce the stack_root_mismatch error | ||
self._create_code_mapping(stack_root="usr/src/getsentry/", source_root="") | ||
response = self.get_success_response( | ||
self.organization.slug, self.project.slug, qs_params={"file": "wrong/file/path"} | ||
) | ||
|
@@ -195,10 +184,11 @@ def test_config_and_source_url(self) -> None: | |
with patch.object( | ||
ExampleIntegration, "get_stacktrace_link", return_value="https://sourceurl.com/" | ||
): | ||
cm = self._create_code_mapping(stack_root="usr/src/getsentry/", source_root="") | ||
response = self.get_success_response( | ||
self.organization.slug, self.project.slug, qs_params={"file": self.filepath} | ||
) | ||
assert response.data["config"] == self.expected_configurations(self.code_mapping1) | ||
assert response.data["config"] == self.expected_configurations(cm) | ||
assert response.data["sourceUrl"] == "https://sourceurl.com/" | ||
assert response.data["integrations"] == [serialized_integration(self.integration)] | ||
|
||
|
@@ -207,6 +197,8 @@ def test_file_no_stack_root_match(self, mock_integration: MagicMock) -> None: | |
# Pretend that the file was not found in the repository | ||
mock_integration.return_value = None | ||
|
||
# At least one code mapping to produce the stack_root_mismatch error | ||
self._create_code_mapping(stack_root="usr/src/getsentry/", source_root="") | ||
response = self.get_success_response( | ||
self.organization.slug, | ||
self.project.slug, | ||
|
Oops, something went wrong.
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.
The organization is not used within the function.