mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
Add step test data for update_files() in Gerrit module
Thus downstream recipes could run "train" without explicit mock data everywhere. BUG=1293270 TEST=train Recipe-Nontrivial-Roll: build Recipe-Nontrivial-Roll: chromiumos Recipe-Nontrivial-Roll: build_limited Recipe-Nontrivial-Roll: chrome_release Change-Id: I09f6a27097f400dabd990f6ef61e301a75a39691 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3502768 Reviewed-by: Josip Sokcevic <sokcevic@google.com> Commit-Queue: Xinan Lin <linxinan@chromium.org>
This commit is contained in:
@@ -325,7 +325,9 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
params=frozenset(['status=NEW']),
|
||||
cc_list=frozenset([]),
|
||||
submit=False,
|
||||
submit_later=False):
|
||||
submit_later=False,
|
||||
step_test_data_create_change=None,
|
||||
step_test_data_submit_change=None):
|
||||
"""Update a set of files by creating and submitting a Gerrit CL.
|
||||
|
||||
Args:
|
||||
@@ -342,6 +344,10 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
* submit_later: If this change has related CLs, we may want to commit
|
||||
them in a chain. So only set Bot-Commit+1, making it ready for
|
||||
submit together. Ignored if submit is True.
|
||||
* step_test_data_create_change: Optional mock test data for the step
|
||||
create gerrit change.
|
||||
* step_test_data_submit_change: Optional mock test data for the step
|
||||
submit gerrit change.
|
||||
|
||||
Returns:
|
||||
A ChangeInfo dictionary as documented here:
|
||||
@@ -368,7 +374,12 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
command.extend(['-p', p])
|
||||
for cc in cc_list:
|
||||
command.extend(['--cc', cc])
|
||||
step_result = self('create change at (%s %s)' % (project, branch), command)
|
||||
step_test_data = step_test_data_create_change or (
|
||||
lambda: self.test_api.update_files_response_data())
|
||||
|
||||
step_result = self('create change at (%s %s)' % (project, branch),
|
||||
command,
|
||||
step_test_data=step_test_data)
|
||||
change = int(step_result.json.output.get('_number'))
|
||||
step_result.presentation.links['change %d' %
|
||||
change] = '%s/#/q/%d' % (host, change)
|
||||
@@ -431,5 +442,9 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
'--json_file',
|
||||
self.m.json.output(),
|
||||
]
|
||||
step_result = self('submit change %d' % change, submit_cmd)
|
||||
step_test_data = step_test_data_submit_change or (
|
||||
lambda: self.test_api.update_files_response_data(status='MERGED'))
|
||||
step_result = self('submit change %d' % change,
|
||||
submit_cmd,
|
||||
step_test_data=step_test_data)
|
||||
return step_result.json.output
|
||||
|
||||
@@ -154,6 +154,7 @@
|
||||
"@@@STEP_LOG_LINE@json.output@ \"change_id\": \"Ideadbeef\", @@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"created\": \"2017-01-30 13:11:20.000000000\", @@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"has_review_started\": false, @@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"id\": \"fully~qualified~changeid\", @@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"project\": \"chromium/src\", @@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"revisions\": {@@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"184ebe53805e102605d11f6b143486d15c23a09c\": {@@@",
|
||||
@@ -203,6 +204,7 @@
|
||||
"@@@STEP_LOG_LINE@json.output@ \"change_id\": \"Ideadbeef\", @@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"created\": \"2017-01-30 13:11:20.000000000\", @@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"has_review_started\": false, @@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"id\": \"fully~qualified~changeid\", @@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"project\": \"chromium/src\", @@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"revisions\": {@@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"184ebe53805e102605d11f6b143486d15c23a09c\": {@@@",
|
||||
@@ -355,6 +357,7 @@
|
||||
"@@@STEP_LOG_LINE@json.output@ \"change_id\": \"Ideadbeef\", @@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"created\": \"2017-01-30 13:11:20.000000000\", @@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"has_review_started\": false, @@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"id\": \"fully~qualified~changeid\", @@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"project\": \"chromium/src\", @@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"revisions\": {@@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"184ebe53805e102605d11f6b143486d15c23a09c\": {@@@",
|
||||
@@ -413,6 +416,7 @@
|
||||
"@@@STEP_LOG_LINE@json.output@ \"change_id\": \"Ideadbeef\", @@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"created\": \"2017-01-30 13:11:20.000000000\", @@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"has_review_started\": false, @@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"id\": \"fully~qualified~changeid\", @@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"project\": \"chromium/src\", @@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"revisions\": {@@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"184ebe53805e102605d11f6b143486d15c23a09c\": {@@@",
|
||||
@@ -462,6 +466,7 @@
|
||||
"@@@STEP_LOG_LINE@json.output@ \"change_id\": \"Ideadbeef\", @@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"created\": \"2017-01-30 13:11:20.000000000\", @@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"has_review_started\": false, @@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"id\": \"fully~qualified~changeid\", @@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"project\": \"chromium/src\", @@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"revisions\": {@@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"184ebe53805e102605d11f6b143486d15c23a09c\": {@@@",
|
||||
@@ -588,6 +593,7 @@
|
||||
"@@@STEP_LOG_LINE@json.output@ \"change_id\": \"Ideadbeef\", @@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"created\": \"2017-01-30 13:11:20.000000000\", @@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"has_review_started\": false, @@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"id\": \"fully~qualified~changeid\", @@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"project\": \"chromium/src\", @@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"revisions\": {@@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"184ebe53805e102605d11f6b143486d15c23a09c\": {@@@",
|
||||
@@ -686,6 +692,7 @@
|
||||
"@@@STEP_LOG_LINE@json.output@ \"change_id\": \"Ideadbeef\", @@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"created\": \"2017-01-30 13:11:20.000000000\", @@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"has_review_started\": false, @@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"id\": \"fully~qualified~changeid\", @@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"project\": \"chromium/src\", @@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"revisions\": {@@@",
|
||||
"@@@STEP_LOG_LINE@json.output@ \"184ebe53805e102605d11f6b143486d15c23a09c\": {@@@",
|
||||
|
||||
@@ -12,6 +12,7 @@ class GerritTestApi(recipe_test_api.RecipeTestApi):
|
||||
# Exemplary change. Note: This contains only a subset of the key/value pairs
|
||||
# present in production to limit recipe simulation output.
|
||||
data = {
|
||||
'id': 'fully~qualified~changeid',
|
||||
'status': 'NEW',
|
||||
'created': '2017-01-30 13:11:20.000000000',
|
||||
'_number': str(change_number),
|
||||
|
||||
Reference in New Issue
Block a user