Commit 0293956d authored by Andrii Shyshkalov's avatar Andrii Shyshkalov Committed by Commit Bot

git cl tests: refactor gerrit base calls for readability.

R=agable@chromium.org
BUG=689652

Change-Id: I3074eeef2b939d64bcd2e537bbc7ee288241bd79
Reviewed-on: https://chromium-review.googlesource.com/443108
Commit-Queue: Andrii Shyshkalov <tandrii@chromium.org>
Reviewed-by: 's avatarAaron Gable <agable@chromium.org>
parent ffb3c439
...@@ -1134,14 +1134,16 @@ class TestGitCl(TestCase): ...@@ -1134,14 +1134,16 @@ class TestGitCl(TestCase):
@classmethod @classmethod
def _gerrit_base_calls(cls, issue=None, fetched_description=None): def _gerrit_base_calls(cls, issue=None, fetched_description=None):
return [ calls = [
((['git', 'symbolic-ref', 'HEAD'],), 'master'), ((['git', 'symbolic-ref', 'HEAD'],), 'master'),
((['git', 'config', 'branch.master.git-cl-similarity'],), ((['git', 'config', 'branch.master.git-cl-similarity'],),
CERR1), CERR1),
((['git', 'symbolic-ref', 'HEAD'],), 'master'), ((['git', 'symbolic-ref', 'HEAD'],), 'master'),
((['git', 'config', '--bool', 'branch.master.git-find-copies'],), ((['git', 'config', '--bool', 'branch.master.git-find-copies'],),
CERR1), CERR1),
] + cls._is_gerrit_calls(True) + [ ]
calls += cls._is_gerrit_calls(True)
calls += [
((['git', 'symbolic-ref', 'HEAD'],), 'master'), ((['git', 'symbolic-ref', 'HEAD'],), 'master'),
((['git', 'config', 'branch.master.rietveldissue'],), CERR1), ((['git', 'config', 'branch.master.rietveldissue'],), CERR1),
((['git', 'config', 'branch.master.gerritissue'],), ((['git', 'config', 'branch.master.gerritissue'],),
...@@ -1152,7 +1154,11 @@ class TestGitCl(TestCase): ...@@ -1152,7 +1154,11 @@ class TestGitCl(TestCase):
'refs/remotes/origin/master'],), 'refs/remotes/origin/master'],),
'fake_ancestor_sha'), 'fake_ancestor_sha'),
# Calls to verify branch point is ancestor # Calls to verify branch point is ancestor
] + cls._gerrit_ensure_auth_calls(issue=issue) + ([ ]
calls += cls._gerrit_ensure_auth_calls(issue=issue)
if issue:
calls += [
(('GetChangeDetail', 'chromium-review.googlesource.com', (('GetChangeDetail', 'chromium-review.googlesource.com',
'123456', ['CURRENT_REVISION', 'CURRENT_COMMIT']), '123456', ['CURRENT_REVISION', 'CURRENT_COMMIT']),
{ {
...@@ -1163,9 +1169,11 @@ class TestGitCl(TestCase): ...@@ -1163,9 +1169,11 @@ class TestGitCl(TestCase):
}}, }},
'status': 'NEW', 'status': 'NEW',
}), }),
] if issue else [ ]
]) + cls._git_sanity_checks('fake_ancestor_sha', 'master',
get_remote_branch=False) + [ calls += cls._git_sanity_checks('fake_ancestor_sha', 'master',
get_remote_branch=False)
calls += [
((['git', 'rev-parse', '--show-cdup'],), ''), ((['git', 'rev-parse', '--show-cdup'],), ''),
((['git', 'rev-parse', 'HEAD'],), '12345'), ((['git', 'rev-parse', 'HEAD'],), '12345'),
...@@ -1174,18 +1182,23 @@ class TestGitCl(TestCase): ...@@ -1174,18 +1182,23 @@ class TestGitCl(TestCase):
'fake_ancestor_sha...', '.'],), 'fake_ancestor_sha...', '.'],),
'M\t.gitignore\n'), 'M\t.gitignore\n'),
((['git', 'config', 'branch.master.gerritpatchset'],), CERR1), ((['git', 'config', 'branch.master.gerritpatchset'],), CERR1),
] + ([ ]
] if issue else [
if not issue:
calls += [
((['git', ((['git',
'log', '--pretty=format:%s%n%n%b', 'fake_ancestor_sha...'],), 'log', '--pretty=format:%s%n%n%b', 'fake_ancestor_sha...'],),
'foo'), 'foo'),
]) + [ ]
calls += [
((['git', 'config', 'user.email'],), 'me@example.com'), ((['git', 'config', 'user.email'],), 'me@example.com'),
((['git', ((['git',
'diff', '--no-ext-diff', '--stat', '-l100000', '-C50', 'diff', '--no-ext-diff', '--stat', '-l100000', '-C50',
'fake_ancestor_sha', 'HEAD'],), 'fake_ancestor_sha', 'HEAD'],),
'+dat'), '+dat'),
] ]
return calls
@classmethod @classmethod
def _gerrit_upload_calls(cls, description, reviewers, squash, def _gerrit_upload_calls(cls, description, reviewers, squash,
......
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