Commit c5f6766a authored by nmilojevic1's avatar nmilojevic1

Add specs for create_from_bundle

- Change response for method
parent a1c10909
......@@ -1131,10 +1131,9 @@ class Repository
end
def create_from_bundle(bundle_path)
raw.create_from_bundle(bundle_path)
after_create
true
raw.create_from_bundle(bundle_path).tap do |result|
after_create if result
end
end
def blobs_metadata(paths, ref = 'HEAD')
......
......@@ -2781,6 +2781,45 @@ describe Repository do
end
end
describe '#create_from_bundle' do
let(:project) { create(:project) }
let(:repository) { project.repository }
let(:valid_bundle_path) { File.join(Dir.tmpdir, "repo-#{SecureRandom.hex}.bundle") }
let(:raw_repository) { repository.raw }
before do
allow(raw_repository).to receive(:create_from_bundle).and_return({})
end
after do
FileUtils.rm_rf(valid_bundle_path)
end
it 'calls out to the raw_repository to create a repo from bundle' do
expect(raw_repository).to receive(:create_from_bundle)
repository.create_from_bundle(valid_bundle_path)
end
it 'calls after_create' do
expect(repository).to receive(:after_create)
repository.create_from_bundle(valid_bundle_path)
end
context 'when exception is raised' do
before do
allow(raw_repository).to receive(:create_from_bundle).and_raise(::Gitlab::Git::BundleFile::InvalidBundleError)
end
it 'after_create is not executed' do
expect(repository).not_to receive(:after_create)
expect {repository.create_from_bundle(valid_bundle_path)}.to raise_error(::Gitlab::Git::BundleFile::InvalidBundleError)
end
end
end
describe "#blobs_metadata" do
let_it_be(:project) { create(:project, :repository) }
let(:repository) { project.repository }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment