2017-09-10 17:25:29 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Gitlab::GitalyClient::RepositoryService do
|
2018-03-17 18:26:18 +05:30
|
|
|
let(:project) { create(:project) }
|
2017-09-10 17:25:29 +05:30
|
|
|
let(:storage_name) { project.repository_storage }
|
2018-03-17 18:26:18 +05:30
|
|
|
let(:relative_path) { project.disk_path + '.git' }
|
2017-09-10 17:25:29 +05:30
|
|
|
let(:client) { described_class.new(project.repository) }
|
|
|
|
|
|
|
|
describe '#exists?' do
|
2018-03-17 18:26:18 +05:30
|
|
|
it 'sends a repository_exists message' do
|
2017-09-10 17:25:29 +05:30
|
|
|
expect_any_instance_of(Gitaly::RepositoryService::Stub)
|
2018-03-17 18:26:18 +05:30
|
|
|
.to receive(:repository_exists)
|
2017-09-10 17:25:29 +05:30
|
|
|
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
|
2018-03-17 18:26:18 +05:30
|
|
|
.and_return(double(exists: true))
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
client.exists?
|
|
|
|
end
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
describe '#garbage_collect' do
|
|
|
|
it 'sends a garbage_collect message' do
|
|
|
|
expect_any_instance_of(Gitaly::RepositoryService::Stub)
|
|
|
|
.to receive(:garbage_collect)
|
|
|
|
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
|
|
|
|
.and_return(double(:garbage_collect_response))
|
|
|
|
|
|
|
|
client.garbage_collect(true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#repack_full' do
|
|
|
|
it 'sends a repack_full message' do
|
|
|
|
expect_any_instance_of(Gitaly::RepositoryService::Stub)
|
|
|
|
.to receive(:repack_full)
|
|
|
|
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
|
|
|
|
.and_return(double(:repack_full_response))
|
|
|
|
|
|
|
|
client.repack_full(true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#repack_incremental' do
|
|
|
|
it 'sends a repack_incremental message' do
|
|
|
|
expect_any_instance_of(Gitaly::RepositoryService::Stub)
|
|
|
|
.to receive(:repack_incremental)
|
|
|
|
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
|
|
|
|
.and_return(double(:repack_incremental_response))
|
|
|
|
|
|
|
|
client.repack_incremental
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#repository_size' do
|
|
|
|
it 'sends a repository_size message' do
|
|
|
|
expect_any_instance_of(Gitaly::RepositoryService::Stub)
|
|
|
|
.to receive(:repository_size)
|
|
|
|
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
|
|
|
|
.and_return(size: 0)
|
|
|
|
|
|
|
|
client.repository_size
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#apply_gitattributes' do
|
|
|
|
let(:revision) { 'master' }
|
|
|
|
|
|
|
|
it 'sends an apply_gitattributes message' do
|
|
|
|
expect_any_instance_of(Gitaly::RepositoryService::Stub)
|
|
|
|
.to receive(:apply_gitattributes)
|
|
|
|
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
|
|
|
|
.and_return(double(:apply_gitattributes_response))
|
|
|
|
|
|
|
|
client.apply_gitattributes(revision)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#has_local_branches?' do
|
|
|
|
it 'sends a has_local_branches message' do
|
|
|
|
expect_any_instance_of(Gitaly::RepositoryService::Stub)
|
|
|
|
.to receive(:has_local_branches)
|
|
|
|
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
|
|
|
|
.and_return(double(value: true))
|
|
|
|
|
|
|
|
expect(client.has_local_branches?).to be(true)
|
|
|
|
end
|
|
|
|
end
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|