This repository was archived by the owner on Jul 19, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Give an OK of false if the PR comment exists #56
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class CC::Service::Invocation | ||
class WithReturnValues | ||
def initialize(invocation, message = nil) | ||
@invocation = invocation | ||
@message = message || "An internal error happened" | ||
end | ||
|
||
def call | ||
result = @invocation.call | ||
if result.nil? | ||
{ ok: false, message: @message } | ||
else | ||
result | ||
end | ||
end | ||
end | ||
end | ||
|
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require File.expand_path('../helper', __FILE__) | ||
|
||
class InvocationReturnValuesTest < CC::Service::TestCase | ||
def test_success_returns_upstream_result | ||
handler = CC::Service::Invocation::WithReturnValues.new( | ||
lambda { :return_value }, | ||
"error message" | ||
) | ||
|
||
assert_equal :return_value, handler.call | ||
end | ||
|
||
def test_empty_results_returns_hash | ||
handler = CC::Service::Invocation::WithReturnValues.new( | ||
lambda { nil }, | ||
"error message" | ||
) | ||
|
||
assert_equal( {ok: false, message: "error message"}, handler.call ) | ||
end | ||
end |
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
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.
Why was the
add_comment
check removed?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.
We are actually relying on these checks to be here (and in
#update_status
) in our other PR 😄 #55There 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.
Okay - we resolved our differences and are no longer relying on the config check that @jyurek removed here - so #55 should be compatible with this PR now
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.
@marshally Because the check actually happens here: https://github.com/codeclimate/codeclimate-services/blob/jy-do-not-allow-nil-branches/lib/cc/services/github_pull_requests.rb#L53 and this check only served to muddy the waters about what was happening.