Commit 0688c989 authored by Sushil Khanchi's avatar Sushil Khanchi 🐨

hgitaly-commit: add Rspec tests for commits_by_message

--HG--
branch : heptapod-stable
parent 4503003c4fa9
......@@ -209,6 +209,102 @@ def gitsha(sha)
end
end
describe 'commit_service#find_commits_by_message' do
subject! { non_empty_repository }
before do
prepare_repo
end
after do
subject.remove
end
def hgsha(rev)
subject.hgsha_from_rev(rev)
end
def gitsha(sha)
hg_git_repository.hg_git_invalidate_maps!
hg_git_repository.sha_from_hgsha(sha)
end
# repo structure:
#
# o changeset: 2: Commit bar
# |
# | o changeset: 1: Commit car (branch: stable)
# |/
# o changeset: 0: Commit 0
#
let!(:offset) { 86400 } # seconds in 24 hours
let(:prepare_repo) {
hg_commit(subject, 'car', par: '0', branch: 'stable',
date: "#{offset} 0")
hg_commit(subject, 'bar', par: '0', date: "#{offset * 2} 0")
}
let!(:hgsha_0) { hgsha('0') }
let!(:hgsha_1) { hgsha('1') }
let!(:hgsha_2) { hgsha('2') }
let!(:gitsha_0) { gitsha(hgsha_0) }
let!(:gitsha_1) { gitsha(hgsha_1) }
let!(:gitsha_2) { gitsha(hgsha_2) }
it 'query' do
commits = subject.gitaly_commit_client.commits_by_message("commit").map(&:id)
expect(commits).to eq([hgsha_2, hgsha_0])
commits = subject.gitaly_commit_client.commits_by_message("bar").map(&:id)
expect(commits).to eq([hgsha_2])
commits = subject.gitaly_commit_client.commits_by_message("car").map(&:id)
expect(commits).to eq([])
# consistency with HgGitRepository
commits = hg_git_repository.gitaly_commit_client.commits_by_message(
"commit"
).map(&:id)
expect(commits).to eq([gitsha_2, gitsha_0])
commits = hg_git_repository.gitaly_commit_client.commits_by_message(
"bar"
).map(&:id)
expect(commits).to eq([gitsha_2])
commits = hg_git_repository.gitaly_commit_client.commits_by_message(
"car"
).map(&:id)
expect(commits).to eq([])
end
it 'query+revision' do
commits = subject.gitaly_commit_client.commits_by_message(
"car", revision: "branch/stable",
).map(&:id)
expect(commits).to eq([hgsha_1])
# consistency with HgGitRepository
commits = hg_git_repository.gitaly_commit_client.commits_by_message(
"car", revision: "branch/stable",
).map(&:id)
expect(commits).to eq([gitsha_1])
end
it 'query+revision+path' do
commits = subject.gitaly_commit_client.commits_by_message(
"commit", path: "foo",
).map(&:id)
expect(commits).to eq([hgsha_0])
# consistency with HgGitRepository
commits = hg_git_repository.gitaly_commit_client.commits_by_message(
"commit", path: "foo",
).map(&:id)
expect(commits).to eq([gitsha_0])
end
end
describe '#commit_stats' do
subject! { non_empty_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