summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-10-19 16:16:30 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-10-19 16:16:30 +0200
commit7977a20bb4b095781f0328aff2e5e90f22cf6699 (patch)
treed516b8fa88463a2a933122979f84119c935ceb12 /spec
parentd9780bc0af7afe79f22b22dc6ae6d7392ecf779f (diff)
downloadgitlab-ce-7977a20bb4b095781f0328aff2e5e90f22cf6699.tar.gz
Extend error message in case of HTTP errors in `include`
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/ci/config/external/file/remote_spec.rb40
1 files changed, 37 insertions, 3 deletions
diff --git a/spec/lib/gitlab/ci/config/external/file/remote_spec.rb b/spec/lib/gitlab/ci/config/external/file/remote_spec.rb
index e4682852014..f65a5a1c727 100644
--- a/spec/lib/gitlab/ci/config/external/file/remote_spec.rb
+++ b/spec/lib/gitlab/ci/config/external/file/remote_spec.rb
@@ -105,10 +105,44 @@ describe Gitlab::Ci::Config::External::File::Remote do
end
describe "#error_message" do
- let(:location) { 'not-valid://gitlab.com/gitlab-org/gitlab-ce/blob/1234/.gitlab-ci-1.yml' }
+ subject { remote_file.error_message }
- it 'should return an error message' do
- expect(remote_file.error_message).to eq("Remote file `#{location}` does not have a valid address!")
+ context 'when remote file location is not valid' do
+ let(:location) { 'not-valid://gitlab.com/gitlab-org/gitlab-ce/blob/1234/.gitlab-ci-1.yml' }
+
+ it 'returns an error message describing invalid address' do
+ expect(subject).to match /does not have a valid address!/
+ end
+ end
+
+ context 'when timeout error has been raised' do
+ before do
+ WebMock.stub_request(:get, location).to_timeout
+ end
+
+ it 'should returns error message about a timeout' do
+ expect(subject).to match /could not be fetched because of a timeout error!/
+ end
+ end
+
+ context 'when HTTP error has been raised' do
+ before do
+ WebMock.stub_request(:get, location).to_raise(Gitlab::HTTP::Error)
+ end
+
+ it 'should returns error message about a HTTP error' do
+ expect(subject).to match /could not be fetched because of HTTP error!/
+ end
+ end
+
+ context 'when response has 404 status' do
+ before do
+ WebMock.stub_request(:get, location).to_return(body: remote_file_content, status: 404)
+ end
+
+ it 'should returns error message about a timeout' do
+ expect(subject).to match /could not be fetched because of HTTP code `404` error!/
+ end
end
end
end