Commit 7feddf88 authored by Sushil Khanchi's avatar Sushil Khanchi 🐨

hgitaly_commit: add Rspec tests for #get_messages

--HG--
branch : heptapod-stable
parent cc5fd1688a9b
......@@ -138,4 +138,62 @@ def gitsha(sha)
end
end
end
describe '#get_messages' 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 foo
#
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 'returns commit messages for given commit_ids' do
messages = described_class.get_messages(
subject, [hgsha_1, hgsha_0, hgsha_2]
).values
expect(messages).to eq(["Commit car", "Commit foo", "Commit bar"])
# consistency with HgGitRepository
messages = described_class.get_messages(
hg_git_repository, [gitsha_1, gitsha_0, gitsha_2]
).values
expect(messages).to eq(
["Commit car\n\n--HG--\nbranch : stable\n",
"Commit foo\n", "Commit bar\n"]
)
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