Commit 16946368 authored by Sushil Khanchi's avatar Sushil Khanchi 🐨

hgitaly_commit: add Rspec tests for #commit_stats

--HG--
branch : heptapod-stable
parent 0df0080af0ed
......@@ -208,4 +208,56 @@ def gitsha(sha)
end.to raise_error(GRPC::Internal, /object not found/)
end
end
describe '#commit_stats' do
subject! { non_empty_repository }
before do
prepare_repo
end
after do
subject.remove
end
# repo structure:
#
# o changeset: 1 Commit bar
# |
# o changeset: 0 Commit 0
#
let(:prepare_repo) {
subject.hg_call(['up', '0'], user, repository_path)
subject.write_file(subject.hg_full_path + "/bar",
"I am the first line\n"\
"I am the second line\n")
subject.hg_call(['add', "bar"], user, repository_path)
subject.hg_call(['ci', '-m', "Commit bar"],
user, repository_path, for_write: true)
}
it 'returns commit stats for given revision' do
hgsha_1 = subject.hgsha_from_rev('1')
hg_git_repository.hg_git_invalidate_maps!
gitsha_1 = hg_git_repository.sha_from_hgsha(hgsha_1)
stats = subject.gitaly_commit_client.commit_stats(hgsha_1)
expect(stats.additions).to eq(2)
expect(stats.deletions).to eq(0)
# consistency with HgGitRepository
stats = hg_git_repository.gitaly_commit_client.commit_stats(gitsha_1)
expect(stats.additions).to eq(2)
expect(stats.deletions).to eq(0)
end
it 'returns error if unknown commit_id sent' do
expect do
subject.gitaly_commit_client.commit_stats("123notexists321")
end.to raise_error(GRPC::Internal, /object not found/)
# consistency with HgGitRepository
expect do
hg_git_repository.gitaly_commit_client.commit_stats("123notexists321")
end.to raise_error(GRPC::Internal, /object not found/)
end
end
end
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