Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
hgitaly
Commits
fd9fadf22229
Commit
fd9fadf2
authored
Mar 21, 2021
by
Sushil Khanchi
🐨
Browse files
DiffService-FindChangedPaths: add gitaly comparison tests
parent
d05c10cb3f8d
Pipeline
#23705
passed with stages
in 1 minute and 14 seconds
Changes
1
Pipelines
4
Hide whitespace changes
Inline
Side-by-side
tests_with_gitaly/test_diff.py
View file @
fd9fadf2
...
...
@@ -12,6 +12,7 @@
CommitDeltaRequest
,
CommitDiffRequest
,
DiffStatsRequest
,
FindChangedPathsRequest
,
RawDiffRequest
,
RawPatchRequest
,
)
...
...
@@ -457,3 +458,60 @@
do_rpc
(
'git'
,
sha_not_exists
,
git_sha3
)
assert
exc_info_hg
.
value
.
code
()
==
exc_info_git
.
value
.
code
()
assert
exc_info_hg
.
value
.
details
()
==
exc_info_git
.
value
.
details
()
def
test_compare_find_changed_paths
(
gitaly_comparison
):
fixture
=
gitaly_comparison
wrapper_repo
=
fixture
.
gitaly_repo
git_repo
=
fixture
.
git_repo
wrapper
=
fixture
.
hg_repo_wrapper
gl_branch
=
b
'branch/default'
(
wrapper
.
path
/
'foo'
).
write_text
(
'foo content'
)
(
wrapper
.
path
/
'bar'
).
write_text
(
'bar content'
)
ctx0
=
wrapper
.
commit
(
rel_paths
=
[
'foo'
,
'bar'
],
add_remove
=
True
)
git_sha0
=
git_repo
.
branches
()[
gl_branch
][
'sha'
]
(
wrapper
.
path
/
'zoo'
).
write_text
(
'zoo content'
)
(
wrapper
.
path
/
'foo'
).
write_text
(
'foo content modified'
)
(
wrapper
.
path
/
'bar'
).
unlink
()
wrapper
.
command
(
b
'rm'
,
wrapper
.
repo
.
root
+
b
'/bar'
)
ctx1
=
wrapper
.
commit
(
rel_paths
=
[
'foo'
,
'bar'
,
'zoo'
],
add_remove
=
True
)
git_sha1
=
git_repo
.
branches
()[
gl_branch
][
'sha'
]
diff_stubs
=
dict
(
git
=
DiffServiceStub
(
fixture
.
gitaly_channel
),
hg
=
DiffServiceStub
(
fixture
.
hgitaly_channel
)
)
def
do_rpc
(
vcs
,
commits
):
request
=
FindChangedPathsRequest
(
repository
=
wrapper_repo
,
commits
=
commits
,
)
response
=
diff_stubs
[
vcs
].
FindChangedPaths
(
request
)
final
=
[]
for
resp
in
response
:
paths
=
sorted
(
resp
.
paths
,
key
=
lambda
o
:
o
.
path
)
final
.
append
(
paths
)
return
final
# case 1: actual test
assert
do_rpc
(
'git'
,
[
git_sha1
])
==
do_rpc
(
'hg'
,
[
ctx1
.
hex
()])
# Note: khanchi97: As per the command used by gitaly for FindChangedPaths
# cmd: `git diff-tree --stdin -z -m -r --name-status --no-renames`
# `--no-commit-id --diff-filter=AMDTC`
# -> git doesn't return anything for the first commit, although I assume
# it should, so not testing for ctx0 for now.
# case 2: when commit_id does not correspond to a commit
sha_not_exists
=
b
'deadnode'
*
5
with
pytest
.
raises
(
grpc
.
RpcError
)
as
exc_info_hg
:
do_rpc
(
'hg'
,
[
ctx0
.
hex
(),
sha_not_exists
])
with
pytest
.
raises
(
grpc
.
RpcError
)
as
exc_info_git
:
do_rpc
(
'git'
,
[
git_sha0
,
sha_not_exists
])
assert
exc_info_hg
.
value
.
code
()
==
exc_info_git
.
value
.
code
()
assert
exc_info_hg
.
value
.
details
()
==
exc_info_git
.
value
.
details
()
Georges Racinet
🦑
@gracinet
mentioned in commit
9d24714a41f9
·
Jul 01, 2021
mentioned in commit
9d24714a41f9
mentioned in commit 9d24714a41f982eed1a73cac990ac0897a464519
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment