Read about our upcoming Code of Conduct on this issue

Commit 8e47c4cf authored by Sushil Khanchi's avatar Sushil Khanchi 🐨
Browse files

HgitalyRepository: Rspec tests for ListCommitByRefName

--HG--
branch : heptapod
parent 07effe0ded38
Pipeline #13787 skipped with stages
......@@ -732,4 +732,62 @@ def hg_commit(cid, topic: nil)
end
end
end
describe '#list_commits_by_ref_name' do
subject! { non_empty_repository }
def hg_commit(cid, topic: nil)
if topic
subject.hg_call(['topic', topic], user, repository_path, for_write: true)
end
subject.write_file(subject.hg_full_path + "/file#{cid}", "line\n")
subject.hg_call(["add", "file#{cid}"], user, repository_path)
subject.hg_call(['ci', '-m', "Commit #{cid}", '--config',
'experimental.single-head-per-branch=False'],
user, repository_path, for_write: true)
end
# repo structure:
#
# 2 (topic/default/feature)
# |
# | 1 (branch/default)
# |/
# 0
#
let(:prepare_repo) {
subject.hg_call(['up', '0'], user, repository_path)
hg_commit(1)
subject.hg_call(['up', '0'], user, repository_path)
hg_commit(2, topic: 'feature')
}
before do
prepare_repo
end
after do
subject.remove
end
it 'return commits corresponding the given ref names' do
hg_sha1 = subject.hgsha_from_rev('1')
hg_sha2 = subject.hgsha_from_rev('2')
hg_git_repository.hg_git_invalidate_maps!
git_sha1 = hg_git_repository.sha_from_hgsha(hg_sha1)
git_sha2 = hg_git_repository.sha_from_hgsha(hg_sha2)
response = subject.list_commits_by_ref_name(['branch/default', 'topic/default/feature', 'does_not_exists'])
expect(response.keys.count).to eq 2
expect(response['topic/default/feature'].id).to eq hg_sha2
expect(response['branch/default'].id).to eq hg_sha1
expect(response).not_to have_key 'nonexistent'
# consistency with HgGitRepository
response = hg_git_repository.list_commits_by_ref_name(['branch/default', 'topic/default/feature', 'does_not_exists'])
expect(response.keys.count).to eq 2
expect(response['topic/default/feature'].id).to eq git_sha2
expect(response['branch/default'].id).to eq git_sha1
expect(response).not_to have_key 'nonexistent'
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