Skip to content
This repository was archived by the owner on Nov 8, 2018. It is now read-only.

Commit 520d814

Browse files
committed
Add tests and metadata output for adding labels.
1 parent ec53c86 commit 520d814

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

assets/lib/commands/out.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ def output
6868

6969
if params.label
7070
Octokit.add_labels_to_an_issue(input.source.repo, id, [params.label])
71+
metadata << { 'name' => 'label', 'value' => params.label }
7172
end
7273

7374
if params.merge.method

spec/commands/out_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,26 @@ def stub_json(method, uri, body)
195195
end
196196
end
197197

198+
context 'when setting a status with a label' do
199+
before do
200+
stub_request(:post, "https://api.github.com/repos/jtarchie/test/issues/1/labels").with(
201+
body: "[\"test_label\"]").to_return(
202+
status: 200, body: "", headers: {})
203+
end
204+
it 'posts a comment to the PR\'s SHA' do
205+
stub_status_post
206+
stub_json(:post, 'https://api.github.com:443/repos/jtarchie/test/issues/1/comments', id: 1)
207+
208+
output, = put('params' => { 'status' => 'success', 'path' => 'resource', 'label' => 'test_label' }, 'source' => { 'repo' => 'jtarchie/test' })
209+
expect(output).to eq('version' => { 'ref' => @sha, 'pr' => '1' },
210+
'metadata' => [
211+
{ 'name' => 'status', 'value' => 'success' },
212+
{ 'name' => 'url', 'value' => 'http://example.com' },
213+
{ 'name' => 'label', 'value' => 'test_label' },
214+
])
215+
end
216+
end
217+
198218
context 'when the pull request is being release' do
199219
context 'and the build passed' do
200220
it 'sets into success mode' do

0 commit comments

Comments
 (0)