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
QUA-360: Add skip diff coverage method #152
Merged
+171
−19
Merged
Changes from all commits
Commits
Show all changes
3 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 |
---|---|---|
|
@@ -36,6 +36,7 @@ def self.load_services | |
issue | ||
pull_request | ||
pull_request_coverage | ||
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.
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. Were you able to find out why this is requested?? It's the available services names, so you can call it like
|
||
pull_request_diff_coverage | ||
quality | ||
snapshot | ||
test | ||
|
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,123 @@ | ||
require "spec_helper" | ||
|
||
describe CC::PullRequests do | ||
shared_examples "receive method" do | ||
before do | ||
allow(instance).to receive(:report_status?).and_return(true) | ||
expect(instance).to receive(:setup_http) | ||
end | ||
|
||
context "when the status is valid" do | ||
let(:instance) { CC::PullRequests.new({}, name: "test", state: payload_status) } | ||
let(:response) do | ||
{ | ||
ok: true, | ||
state: 201, | ||
message: "Success", | ||
} | ||
end | ||
|
||
it "calls the corresponding method" do | ||
expect(instance).to receive(expected_method_name) do | ||
instance.instance_variable_set(:@response, response) | ||
end | ||
result = instance.send(method_to_call) | ||
|
||
expect(result).to eq(response) | ||
end | ||
|
||
context "when report_status? is false" do | ||
before { expect(instance).to receive(:report_status?).and_return(false) } | ||
|
||
it "returns unknown status message" do | ||
expect(instance).not_to receive(expected_method_name) | ||
result = instance.send(method_to_call) | ||
|
||
expect(result).to eq({ ok: false, message: "Unknown state" }) | ||
end | ||
end | ||
end | ||
|
||
context "when the status is not valid" do | ||
let(:instance) { CC::PullRequests.new({}, name: "test", status: "invalid_status") } | ||
|
||
it "returns unknown status message" do | ||
expect(instance).not_to receive(expected_method_name) | ||
result = instance.send(method_to_call) | ||
|
||
expect(result).to eq({ ok: false, message: "Unknown state" }) | ||
end | ||
end | ||
end | ||
|
||
describe "#receive_test" do | ||
let(:instance) { CC::PullRequests.new({}, name: "test") } | ||
|
||
before do | ||
expect(instance).to receive(:base_status_url) do |param| | ||
"some_url" + param | ||
end | ||
expect(instance).to receive(:setup_http) | ||
end | ||
|
||
it "makes a raw http test post" do | ||
expect_any_instance_of(CC::Service::HTTP).to receive(:raw_post).with( | ||
"some_url" + ("0" * 40), | ||
{ state: "success" }.to_json | ||
) | ||
|
||
instance.receive_test | ||
end | ||
|
||
context "when raising an HTTPError" do | ||
context "when message is equal to test_status_code" do | ||
it "returns an ok message" do | ||
expect(instance).to receive(:test_status_code) { 777 } | ||
expect(instance).to receive(:raw_post). | ||
and_raise(CC::Service::HTTPError.new("error", status: 777)) | ||
|
||
result = instance.receive_test | ||
expect(result).to include( | ||
ok: true, | ||
status: 777, | ||
message: "Access token is valid" | ||
) | ||
end | ||
end | ||
|
||
context "when message is different than test_status_code" do | ||
it "raises the error" do | ||
expect(instance).to receive(:test_status_code) { 777 } | ||
expect(instance).to receive(:raw_post). | ||
and_raise(CC::Service::HTTPError.new("error", status: 000)) | ||
|
||
expect { instance.receive_test }.to raise_error | ||
end | ||
end | ||
end | ||
end | ||
|
||
describe "#receive_pull_request" do | ||
let(:payload_status) { "skipped" } | ||
let(:expected_method_name) { :update_status_skipped } | ||
let(:method_to_call) { :receive_pull_request } | ||
|
||
it_behaves_like "receive method" | ||
end | ||
|
||
describe "#receive_pull_request_coverage" do | ||
let(:payload_status) { "success" } | ||
let(:expected_method_name) { :update_coverage_status_success } | ||
let(:method_to_call) { :receive_pull_request_coverage } | ||
|
||
it_behaves_like "receive method" | ||
end | ||
|
||
describe "#receive_pull_request_diff_coverage" do | ||
let(:payload_status) { "skipped" } | ||
let(:expected_method_name) { :update_diff_coverage_status_skipped } | ||
let(:method_to_call) { :receive_pull_request_diff_coverage } | ||
|
||
it_behaves_like "receive method" | ||
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.
Is there a reason to pass the
call_method
as a symbol instead of a string? I see that we convert it as a string later in thereceive_request
methodThere 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.
Honestly, there isn't a strong reason. I just felt like it was more readable, but I'm open to change it if you don't feel the same about it
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.
I personally like it as a symbol. I associate symbols with methods better 👍