repo_roll: Use test_api to create properties
Bug: b/341756093
Change-Id: I0adb47f9df3baf33289fafee3de111ae609c0b70
Reviewed-on: https://pigweed-review.googlesource.com/c/infra/recipes/+/236058
Reviewed-by: Taylor Cramer <cramertj@google.com>
Pigweed-Auto-Submit: Rob Mohr <mohrr@google.com>
Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com>
Presubmit-Verified: CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed-service-accounts.iam.gserviceaccount.com>
diff --git a/recipe_modules/repo_roll/test_api.py b/recipe_modules/repo_roll/test_api.py
index 83f40ca..a62fa5a 100644
--- a/recipe_modules/repo_roll/test_api.py
+++ b/recipe_modules/repo_roll/test_api.py
@@ -13,7 +13,7 @@
# the License.
"""Test API for repo_roll."""
-from PB.recipe_modules.pigweed.cipd_roll.package import Package
+from PB.recipe_modules.pigweed.repo_roll.project import Project
from recipe_engine import recipe_test_api
@@ -57,3 +57,6 @@
""".lstrip()
),
)
+
+ def project(self, path_to_update: str) -> Project:
+ return Project(path_to_update=path_to_update)
diff --git a/recipe_modules/repo_roll/tests/full.py b/recipe_modules/repo_roll/tests/full.py
index 5252f39..aaafddc 100644
--- a/recipe_modules/repo_roll/tests/full.py
+++ b/recipe_modules/repo_roll/tests/full.py
@@ -22,7 +22,6 @@
from PB.recipe_engine import result as result_pb2
from PB.go.chromium.org.luci.buildbucket.proto import common as common_pb2
from PB.recipe_modules.pigweed.repo_roll.tests.full import InputProperties
-from PB.recipe_modules.pigweed.repo_roll.project import Project
from recipe_engine import post_process, recipe_test_api
DEPS = [
@@ -75,14 +74,14 @@
def GenTests(api) -> Generator[recipe_test_api.TestData, None, None]:
"""Create tests."""
- def properties(path):
+ def properties(*projects):
props = InputProperties()
- props.projects.append(Project(path_to_update=path))
+ props.projects.extend(projects)
return api.properties(props)
yield api.test(
'success',
- properties(path='a1'),
+ properties(api.repo_roll.project('a1')),
api.buildbucket.ci_build(git_repo='https://foo.googlesource.com/a'),
api.repo_roll.read_step_data('a1'),
api.gitiles.log('a1.log a1', 'A'),
@@ -90,7 +89,7 @@
yield api.test(
'name-not-found',
- properties(path='missing'),
+ properties(api.repo_roll.project('missing')),
api.buildbucket.ci_build(git_repo='https://bar.googlesource.com/b'),
api.repo_roll.read_step_data('missing'),
status='FAILURE',
@@ -98,14 +97,14 @@
yield api.test(
'equivalent',
- properties(path='b2'),
+ properties(api.repo_roll.project('b2')),
api.repo_roll.read_step_data('b2'),
api.gitiles.log('b2.log b2', 'A'),
)
yield api.test(
'upstream-not-set',
- properties(path='c3'),
+ properties(api.repo_roll.project('c3')),
api.buildbucket.ci_build(git_repo='https://bar.googlesource.com/c'),
api.repo_roll.read_step_data('c3'),
api.gitiles.log('c3.log c3', 'A'),
@@ -113,7 +112,7 @@
yield api.test(
'upstream-not-set-revision-not-branch',
- properties(path='d4'),
+ properties(api.repo_roll.project('d4')),
api.buildbucket.ci_build(git_repo='https://bar.googlesource.com/c'),
api.repo_roll.read_step_data('d4'),
status='FAILURE',
@@ -121,42 +120,42 @@
yield api.test(
'no-trigger-with-upstream',
- properties(path='a1'),
+ properties(api.repo_roll.project('a1')),
api.repo_roll.read_step_data('a1'),
api.gitiles.log('a1.log a1', 'A'),
)
yield api.test(
'no-trigger-with-revision-branch',
- properties(path='c3'),
+ properties(api.repo_roll.project('c3')),
api.repo_roll.read_step_data('c3'),
api.gitiles.log('c3.log c3', 'A'),
)
yield api.test(
'no-trigger-with-revision-hash',
- properties(path='d4'),
+ properties(api.repo_roll.project('d4')),
api.repo_roll.read_step_data('d4'),
status='FAILURE',
)
yield api.test(
'no-trigger-with-revision-tag',
- properties(path='e5'),
+ properties(api.repo_roll.project('e5')),
api.repo_roll.read_step_data('e5'),
status='FAILURE',
)
yield api.test(
'backwards',
- properties(path='a1'),
+ properties(api.repo_roll.project('a1')),
api.repo_roll.read_step_data('a1'),
api.gitiles.log('a1.log a1', 'A', n=0),
)
yield api.test(
'host-dot-dot',
- properties(path='f6'),
+ properties(api.repo_roll.project('f6')),
api.buildbucket.ci_build(git_repo='https://host.googlesource.com/f'),
api.repo_roll.read_step_data('f6'),
api.gitiles.log('f6.log f6', 'A'),
@@ -164,7 +163,7 @@
yield api.test(
'dotdot-prefix',
- properties(path='g7'),
+ properties(api.repo_roll.project('g7')),
api.buildbucket.ci_build(
git_repo='https://host.googlesource.com/prefix/g'
),
@@ -174,7 +173,7 @@
yield api.test(
'host-prefix',
- properties(path='h8'),
+ properties(api.repo_roll.project('h8')),
api.buildbucket.ci_build(
git_repo='https://host.googlesource.com/prefix/h'
),
diff --git a/recipes/repo_roller.py b/recipes/repo_roller.py
index db741ad..97d59bb 100644
--- a/recipes/repo_roller.py
+++ b/recipes/repo_roller.py
@@ -126,7 +126,7 @@
'success',
properties(
api,
- Project(path_to_update='a1'),
+ api.repo_roll.project(path_to_update='a1'),
cc_authors_on_rolls=True,
always_cc=True,
),
@@ -140,7 +140,7 @@
'equivalent',
properties(
api,
- Project(path_to_update='b2'),
+ api.repo_roll.project(path_to_update='b2'),
equivalent_remotes=(
(
'https://equiv.googlesource.com/b',
@@ -157,7 +157,7 @@
yield api.test(
'backwards',
- properties(api, Project(path_to_update='a1')),
+ properties(api, api.repo_roll.project(path_to_update='a1')),
api.checkout.ci_test_data(git_repo='https://foo.googlesource.com/a'),
api.repo_roll.read_step_data('a1'),
api.gitiles.log('a1.log a1', 'A', n=0),