diff options
Diffstat (limited to 'spec/tasks/gitlab/gitaly_rake_spec.rb')
-rw-r--r-- | spec/tasks/gitlab/gitaly_rake_spec.rb | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/spec/tasks/gitlab/gitaly_rake_spec.rb b/spec/tasks/gitlab/gitaly_rake_spec.rb index d95baddf546..aaf998a546f 100644 --- a/spec/tasks/gitlab/gitaly_rake_spec.rb +++ b/spec/tasks/gitlab/gitaly_rake_spec.rb @@ -8,7 +8,7 @@ describe 'gitlab:gitaly namespace rake task' do describe 'install' do let(:repo) { 'https://gitlab.com/gitlab-org/gitaly.git' } let(:clone_path) { Rails.root.join('tmp/tests/gitaly').to_s } - let(:tag) { "v#{File.read(Rails.root.join(Gitlab::GitalyClient::SERVER_VERSION_FILE)).chomp}" } + let(:version) { File.read(Rails.root.join(Gitlab::GitalyClient::SERVER_VERSION_FILE)).chomp } context 'no dir given' do it 'aborts and display a help message' do @@ -21,7 +21,7 @@ describe 'gitlab:gitaly namespace rake task' do context 'when an underlying Git command fail' do it 'aborts and display a help message' do expect_any_instance_of(Object). - to receive(:checkout_or_clone_tag).and_raise 'Git error' + to receive(:checkout_or_clone_version).and_raise 'Git error' expect { run_rake_task('gitlab:gitaly:install', clone_path) }.to raise_error 'Git error' end @@ -32,9 +32,9 @@ describe 'gitlab:gitaly namespace rake task' do expect(Dir).to receive(:chdir).with(clone_path) end - it 'calls checkout_or_clone_tag with the right arguments' do + it 'calls checkout_or_clone_version with the right arguments' do expect_any_instance_of(Object). - to receive(:checkout_or_clone_tag).with(tag: tag, repo: repo, target_dir: clone_path) + to receive(:checkout_or_clone_version).with(version: version, repo: repo, target_dir: clone_path) run_rake_task('gitlab:gitaly:install', clone_path) end @@ -48,7 +48,7 @@ describe 'gitlab:gitaly namespace rake task' do context 'gmake is available' do before do - expect_any_instance_of(Object).to receive(:checkout_or_clone_tag) + expect_any_instance_of(Object).to receive(:checkout_or_clone_version) allow_any_instance_of(Object).to receive(:run_command!).with(['gmake']).and_return(true) end @@ -62,7 +62,7 @@ describe 'gitlab:gitaly namespace rake task' do context 'gmake is not available' do before do - expect_any_instance_of(Object).to receive(:checkout_or_clone_tag) + expect_any_instance_of(Object).to receive(:checkout_or_clone_version) allow_any_instance_of(Object).to receive(:run_command!).with(['make']).and_return(true) end @@ -75,4 +75,36 @@ describe 'gitlab:gitaly namespace rake task' do end end end + + describe 'storage_config' do + it 'prints storage configuration in a TOML format' do + config = { + 'default' => { 'path' => '/path/to/default' }, + 'nfs_01' => { 'path' => '/path/to/nfs_01' }, + } + allow(Gitlab.config.repositories).to receive(:storages).and_return(config) + + orig_stdout = $stdout + $stdout = StringIO.new + + header = '' + Timecop.freeze do + header = <<~TOML + # Gitaly storage configuration generated from #{Gitlab.config.source} on #{Time.current.to_s(:long)} + # This is in TOML format suitable for use in Gitaly's config.toml file. + TOML + run_rake_task('gitlab:gitaly:storage_config') + end + + output = $stdout.string + $stdout = orig_stdout + + expect(output).to include(header) + + parsed_output = TOML.parse(output) + config.each do |name, params| + expect(parsed_output['storage']).to include({ 'name' => name, 'path' => params['path'] }) + end + end + end end |