Skip to content

Commit da66ef5

Browse files
committed
write tests for ATC_EXTERNAL_ENDPOINT
1 parent f930962 commit da66ef5

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

spec/integration/out_spec.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def request_body(method, url)
3333

3434
proxy.stub("https://api.github.com:443/repos/jtarchie/test/statuses/#{@sha}")
3535
.and_return(json: [])
36+
ENV['BUILD_ID'] = '1234'
3637
end
3738

3839
context 'when the git repo has no pull request meta information' do
@@ -108,8 +109,21 @@ def request_body(method, url)
108109
proxy.stub("https://api.github.com:443/repos/jtarchie/test/statuses/#{@sha}", method: :post)
109110

110111
put(params: { status: 'success', path: 'resource' }, source: { repo: 'jtarchie/test', base_url: 'http://example.com'})
112+
113+
body = request_body('post', "https://api.github.com:443/repos/jtarchie/test/statuses/#{@sha}")
114+
expect(JSON.parse(body)).to include('target_url' => 'http://example.com/builds/1234')
115+
end
116+
end
117+
118+
context 'with no base_url defined, but with ATC_EXTERNAL_URL defined' do
119+
it 'sets the target_url for status' do
120+
ENV['ATC_EXTERNAL_URL'] = 'http://atc-endpoint.com'
121+
proxy.stub("https://api.github.com:443/repos/jtarchie/test/statuses/#{@sha}", method: :post)
122+
123+
put(params: { status: 'success', path: 'resource' }, source: { repo: 'jtarchie/test'})
124+
111125
body = request_body('post', "https://api.github.com:443/repos/jtarchie/test/statuses/#{@sha}")
112-
expect(JSON.parse(body)).to include('target_url' => 'http://example.com/builds/')
126+
expect(JSON.parse(body)).to include('target_url' => 'http://atc-endpoint.com/builds/1234')
113127
end
114128
end
115129
end

0 commit comments

Comments
 (0)