Commit 861896c5 authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

HGitaly RSpec tests for Blob/Tree in fully native mode

The tests are conditionally skipped according to the
HGitaly server version.

There *is* a small discrepancy: line ending in commit message,
but it doesn't actually lie in the code being tested, it should
be a comparison case in `FindCommit`.

Comparing with `HgGitRepository` is still useful for these
tests at this point, because there is some plumbery involved
on the Rails side for the HGitaly1 mode, and even in fully native
mode, it's good to check that nothing goes wrong. When the dust
settles on all this, though, it will be removable: actual thorough
comparisons are to be done in the testing code of HGitaly.

--HG--
branch : heptapod
parent ea7d9baf84e2
Pipeline #20318 passed with stages
in 15 minutes and 8 seconds
......@@ -8,6 +8,17 @@
include RepoHelpers
include Gitlab::Popen
def skip_if_hgitaly_no_blob_tree
version = RSpec.configuration.hgitaly_version
# Gem version scheme understands the 'dev' scheme of Python PEP 440 somewhat:
# - an alphabetic part always means pre-release and is sorted lexicographically
# - the number after is taken into account
# so actually 'dev0' is greater that 'a1' and 'b1'. That's good enough for now, though.
if version < Gem::Version.new('0.12.0dev1')
skip "Skipped because HGitaly version #{version} does not implement blob/tree methods yet"
end
end
def hgitaly_repo_init
repo = Gitlab::Mercurial::HgitalyRepository.new(
'default', 'hgitaly-repo.git', '', 'group/project')
......@@ -157,7 +168,7 @@ def hgitaly_repo_init
foo_last_commit = hgitaly_repo.list_last_commits_for_tree(
hg_commit_sha, 'foo')['foo']
expect(foo_last_commit.id).to eq(root_hgsha)
expect(foo_last_commit.message).to eq("Commit 0\n")
expect(foo_last_commit.message.strip).to eq("Commit 0")
expect(foo_last_commit.instance_variable_get(:@repository))
.to eq(hgitaly_repo)
......@@ -169,7 +180,7 @@ def hgitaly_repo_init
foo_git_last_commit = hg_git_repo.list_last_commits_for_tree(
git_commit_sha, 'foo')['foo']
expect(foo_git_last_commit.id).to eq(root_gitsha)
expect(foo_git_last_commit.message).to eq("Commit 0\n")
expect(foo_git_last_commit.message.strip).to eq("Commit 0")
expect(foo_git_last_commit.instance_variable_get(:@repository))
.to eq(hg_git_repo)
sub_foo1_git_last_commit = hg_git_repo.list_last_commits_for_tree(
......@@ -183,7 +194,16 @@ def hgitaly_repo_init
hgitaly_repo.is_hgitaly1 = true
end
it_behaves_like 'Blob/Tree basic integration'
it_behaves_like 'Blob/Tree common integration tests'
end
describe 'In fully native mode' do
before do
skip_if_hgitaly_no_blob_tree
hgitaly_repo.is_hgitaly1 = false
end
it_behaves_like 'Blob/Tree common integration tests'
end
# Tell if two blobs have identical instance variables
......
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