diff options
| author | Douwe Maan <douwe@gitlab.com> | 2018-12-13 11:36:09 +0000 |
|---|---|---|
| committer | Douwe Maan <douwe@gitlab.com> | 2018-12-13 11:36:09 +0000 |
| commit | 47dc17bce2e59b403dffa9eacc8b146618dba2c2 (patch) | |
| tree | 544fda407b7df029b0dd122f949fd0dfe3ad9694 /spec | |
| parent | df89099ed954a6673bb8388ef74480940d40a759 (diff) | |
| download | gitlab-shell-47dc17bce2e59b403dffa9eacc8b146618dba2c2.tar.gz | |
Revert "Merge branch 'sh-bump-ruby-version' into 'master'"
This reverts merge request !257
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/gitlab_keys_spec.rb | 14 | ||||
| -rw-r--r-- | spec/gitlab_logger_spec.rb | 8 | ||||
| -rw-r--r-- | spec/gitlab_net_spec.rb | 2 | ||||
| -rw-r--r-- | spec/gitlab_shell_gitlab_shell_spec.rb | 8 | ||||
| -rw-r--r-- | spec/vcr_cassettes/custom-action-ok-not-json.yml | 2 |
5 files changed, 12 insertions, 22 deletions
diff --git a/spec/gitlab_keys_spec.rb b/spec/gitlab_keys_spec.rb index c6be139..f86d00d 100644 --- a/spec/gitlab_keys_spec.rb +++ b/spec/gitlab_keys_spec.rb @@ -5,8 +5,6 @@ require 'stringio' describe GitlabKeys do before do $logger = double('logger').as_null_object - # The default 'auth_file' value from config.yml.example is '/home/git/.ssh/authorized_keys' - allow(GitlabConfig).to receive_message_chain(:new, :auth_file).and_return('/home/git/.ssh/authorized_keys') end describe '.command' do @@ -150,9 +148,7 @@ describe GitlabKeys do context "without file writing" do before do - file = double(:file, puts: nil, chmod: nil, flock: nil) - expect(File).to receive(:open).with(tmp_authorized_keys_path + '.lock', 'w+').and_yield(file) - expect(File).to receive(:open).with(tmp_authorized_keys_path, "a", 0o600).and_yield(file) + expect(gitlab_keys).to receive(:open).and_yield(double(:file, puts: nil, chmod: nil)) end it "should log an add-key event" do @@ -193,8 +189,7 @@ describe GitlabKeys do context "without file writing" do before do - allow(File).to receive(:open).with("#{ROOT_PATH}/config.yml", 'r:bom|utf-8').and_call_original - allow(File).to receive(:open).with('/home/git/.ssh/authorized_keys', 'r+', 384) + allow(gitlab_keys).to receive(:open) allow(gitlab_keys).to receive(:lock).and_yield end @@ -230,8 +225,7 @@ describe GitlabKeys do let(:gitlab_keys) { build_gitlab_keys('clear') } it "should return true" do - allow(File).to receive(:open).with("#{ROOT_PATH}/config.yml", 'r:bom|utf-8').and_call_original - allow(File).to receive(:open).with('/home/git/.ssh/authorized_keys', 'w', 384) + allow(gitlab_keys).to receive(:open) expect(gitlab_keys.send(:clear)).to be_truthy end end @@ -246,7 +240,7 @@ describe GitlabKeys do it 'returns false if opening raises an exception' do expect(gitlab_keys).to receive(:open_auth_file).and_raise("imaginary error") - expect { expect(gitlab_keys.exec).to eq(false) }.to output(/imaginary error/).to_stdout + expect(gitlab_keys.exec).to eq(false) end it 'creates the keys file if it does not exist' do diff --git a/spec/gitlab_logger_spec.rb b/spec/gitlab_logger_spec.rb index d5704c3..a9cd3fb 100644 --- a/spec/gitlab_logger_spec.rb +++ b/spec/gitlab_logger_spec.rb @@ -3,13 +3,11 @@ require_relative '../lib/gitlab_logger' require 'securerandom' describe :convert_log_level do - it "returns desired Logger::<type>" do - expect(convert_log_level(:debug)).to eq(Logger::DEBUG) - end + subject { convert_log_level :extreme } it "converts invalid log level to Logger::INFO" do - expect { convert_log_level(:extreme) }.to output(/WARNING: Unrecognized log level :extreme. Falling back to INFO./).to_stderr - expect(convert_log_level(:extreme)).to eq(Logger::INFO) + expect($stderr).to receive(:puts).at_least(:once) + is_expected.to eq(Logger::INFO) end end diff --git a/spec/gitlab_net_spec.rb b/spec/gitlab_net_spec.rb index 564e5c0..07b772b 100644 --- a/spec/gitlab_net_spec.rb +++ b/spec/gitlab_net_spec.rb @@ -67,7 +67,7 @@ describe GitlabNet, vcr: true do describe '#lfs_authenticate' do context 'lfs authentication succeeded' do - let(:repository_http_path) { URI.join(internal_api_endpoint.sub('/api/v4/internal', ''), project).to_s } + let(:repository_http_path) { URI.join(internal_api_endpoint.sub('api/v4', ''), project).to_s } context 'for download operation' do it 'should return the correct data' do diff --git a/spec/gitlab_shell_gitlab_shell_spec.rb b/spec/gitlab_shell_gitlab_shell_spec.rb index e5342b7..9afeac8 100644 --- a/spec/gitlab_shell_gitlab_shell_spec.rb +++ b/spec/gitlab_shell_gitlab_shell_spec.rb @@ -1,5 +1,4 @@ require_relative 'spec_helper' -require 'open3' describe 'bin/gitlab-shell' do def original_root_path @@ -132,13 +131,12 @@ describe 'bin/gitlab-shell' do def run!(args) cmd = [ - 'SSH_CONNECTION=fake', gitlab_shell_path, args - ].flatten.join(' ') + ].flatten.compact - stdout, _stderr, status = Open3.capture3(cmd) + output = IO.popen({'SSH_CONNECTION' => 'fake'}, cmd, &:read) - [stdout, status] + [output, $?] end end diff --git a/spec/vcr_cassettes/custom-action-ok-not-json.yml b/spec/vcr_cassettes/custom-action-ok-not-json.yml index 405292d..3bfb390 100644 --- a/spec/vcr_cassettes/custom-action-ok-not-json.yml +++ b/spec/vcr_cassettes/custom-action-ok-not-json.yml @@ -46,6 +46,6 @@ http_interactions: - '1.436040' body: encoding: UTF-8 - string: '{' + string: '""' http_version: recorded_at: Fri, 20 Jul 2018 06:18:58 GMT |
