Provide test data for Jiri snapshot
This is to simplify the use of snapshot method so that not every
caller has to provide their own test data.
Change-Id: Ic2ea213470376904387123b07bd7a6e32c435f58
diff --git a/recipe_modules/jiri/api.py b/recipe_modules/jiri/api.py
index b02bbab..daae91e 100644
--- a/recipe_modules/jiri/api.py
+++ b/recipe_modules/jiri/api.py
@@ -89,4 +89,8 @@
return self(*cmd, **kwargs)
def snapshot(self, file, step_test_data=None, **kwargs):
- return self('snapshot', file, step_test_data=step_test_data)
+ return self(
+ 'snapshot', file,
+ step_test_data=step_test_data or self.test_api.example_snapshot,
+ **kwargs
+ )
diff --git a/recipe_modules/jiri/example.expected/basic.json b/recipe_modules/jiri/example.expected/basic.json
index 9cf95c2..bfb86d7 100644
--- a/recipe_modules/jiri/example.expected/basic.json
+++ b/recipe_modules/jiri/example.expected/basic.json
@@ -86,8 +86,7 @@
"@@@STEP_LOG_LINE@jiri.snapshot@@@@",
"@@@STEP_LOG_LINE@jiri.snapshot@<manifest>@@@",
"@@@STEP_LOG_LINE@jiri.snapshot@ <projects>@@@",
- "@@@STEP_LOG_LINE@jiri.snapshot@ <project name=\"manifest\" path=\"manifest\"@@@",
- "@@@STEP_LOG_LINE@jiri.snapshot@ remote=\"https://fuchsia.googlesource.com/manifest\" revision=\"4c2b0da3c06341db5cebe4d02c78c93c3b2bd78b\"/>@@@",
+ "@@@STEP_LOG_LINE@jiri.snapshot@ <project name=\"manifest\" path=\"manifest\" remote=\"https://fuchsia.googlesource.com/manifest\" revision=\"4c2b0da3c06341db5cebe4d02c78c93c3b2bd78b\"/>@@@",
"@@@STEP_LOG_LINE@jiri.snapshot@ </projects>@@@",
"@@@STEP_LOG_LINE@jiri.snapshot@</manifest>@@@",
"@@@STEP_LOG_END@jiri.snapshot@@@"
diff --git a/recipe_modules/jiri/example.expected/basic_fuchsia.json b/recipe_modules/jiri/example.expected/basic_fuchsia.json
index 9cf95c2..bfb86d7 100644
--- a/recipe_modules/jiri/example.expected/basic_fuchsia.json
+++ b/recipe_modules/jiri/example.expected/basic_fuchsia.json
@@ -86,8 +86,7 @@
"@@@STEP_LOG_LINE@jiri.snapshot@@@@",
"@@@STEP_LOG_LINE@jiri.snapshot@<manifest>@@@",
"@@@STEP_LOG_LINE@jiri.snapshot@ <projects>@@@",
- "@@@STEP_LOG_LINE@jiri.snapshot@ <project name=\"manifest\" path=\"manifest\"@@@",
- "@@@STEP_LOG_LINE@jiri.snapshot@ remote=\"https://fuchsia.googlesource.com/manifest\" revision=\"4c2b0da3c06341db5cebe4d02c78c93c3b2bd78b\"/>@@@",
+ "@@@STEP_LOG_LINE@jiri.snapshot@ <project name=\"manifest\" path=\"manifest\" remote=\"https://fuchsia.googlesource.com/manifest\" revision=\"4c2b0da3c06341db5cebe4d02c78c93c3b2bd78b\"/>@@@",
"@@@STEP_LOG_LINE@jiri.snapshot@ </projects>@@@",
"@@@STEP_LOG_LINE@jiri.snapshot@</manifest>@@@",
"@@@STEP_LOG_END@jiri.snapshot@@@"
diff --git a/recipe_modules/jiri/example.expected/basic_jiri.json b/recipe_modules/jiri/example.expected/basic_jiri.json
index 9cf95c2..bfb86d7 100644
--- a/recipe_modules/jiri/example.expected/basic_jiri.json
+++ b/recipe_modules/jiri/example.expected/basic_jiri.json
@@ -86,8 +86,7 @@
"@@@STEP_LOG_LINE@jiri.snapshot@@@@",
"@@@STEP_LOG_LINE@jiri.snapshot@<manifest>@@@",
"@@@STEP_LOG_LINE@jiri.snapshot@ <projects>@@@",
- "@@@STEP_LOG_LINE@jiri.snapshot@ <project name=\"manifest\" path=\"manifest\"@@@",
- "@@@STEP_LOG_LINE@jiri.snapshot@ remote=\"https://fuchsia.googlesource.com/manifest\" revision=\"4c2b0da3c06341db5cebe4d02c78c93c3b2bd78b\"/>@@@",
+ "@@@STEP_LOG_LINE@jiri.snapshot@ <project name=\"manifest\" path=\"manifest\" remote=\"https://fuchsia.googlesource.com/manifest\" revision=\"4c2b0da3c06341db5cebe4d02c78c93c3b2bd78b\"/>@@@",
"@@@STEP_LOG_LINE@jiri.snapshot@ </projects>@@@",
"@@@STEP_LOG_LINE@jiri.snapshot@</manifest>@@@",
"@@@STEP_LOG_END@jiri.snapshot@@@"
diff --git a/recipe_modules/jiri/example.expected/basic_magenta.json b/recipe_modules/jiri/example.expected/basic_magenta.json
index 9cf95c2..bfb86d7 100644
--- a/recipe_modules/jiri/example.expected/basic_magenta.json
+++ b/recipe_modules/jiri/example.expected/basic_magenta.json
@@ -86,8 +86,7 @@
"@@@STEP_LOG_LINE@jiri.snapshot@@@@",
"@@@STEP_LOG_LINE@jiri.snapshot@<manifest>@@@",
"@@@STEP_LOG_LINE@jiri.snapshot@ <projects>@@@",
- "@@@STEP_LOG_LINE@jiri.snapshot@ <project name=\"manifest\" path=\"manifest\"@@@",
- "@@@STEP_LOG_LINE@jiri.snapshot@ remote=\"https://fuchsia.googlesource.com/manifest\" revision=\"4c2b0da3c06341db5cebe4d02c78c93c3b2bd78b\"/>@@@",
+ "@@@STEP_LOG_LINE@jiri.snapshot@ <project name=\"manifest\" path=\"manifest\" remote=\"https://fuchsia.googlesource.com/manifest\" revision=\"4c2b0da3c06341db5cebe4d02c78c93c3b2bd78b\"/>@@@",
"@@@STEP_LOG_LINE@jiri.snapshot@ </projects>@@@",
"@@@STEP_LOG_LINE@jiri.snapshot@</manifest>@@@",
"@@@STEP_LOG_END@jiri.snapshot@@@"
diff --git a/recipe_modules/jiri/example.py b/recipe_modules/jiri/example.py
index 6603d2e..94fe0c7 100644
--- a/recipe_modules/jiri/example.py
+++ b/recipe_modules/jiri/example.py
@@ -29,16 +29,7 @@
api.jiri.update(gc=True, snapshot='snapshot')
# Take a snapshot.
- step_result = api.jiri.snapshot(
- api.raw_io.output(),
- step_test_data=lambda: api.raw_io.test_api.output('''
-<manifest>
- <projects>
- <project name="manifest" path="manifest"
- remote="https://fuchsia.googlesource.com/manifest" revision="4c2b0da3c06341db5cebe4d02c78c93c3b2bd78b"/>
- </projects>
-</manifest>
-'''))
+ step_result = api.jiri.snapshot(api.raw_io.output())
snapshot = step_result.raw_io.output
step_result.presentation.logs['jiri.snapshot'] = snapshot.splitlines()
diff --git a/recipe_modules/jiri/test_api.py b/recipe_modules/jiri/test_api.py
index 0c974dc..34c0167 100644
--- a/recipe_modules/jiri/test_api.py
+++ b/recipe_modules/jiri/test_api.py
@@ -23,3 +23,12 @@
}
for project in projects
])
+
+ def example_snapshot(self):
+ return self.m.raw_io.output('''
+<manifest>
+ <projects>
+ <project name="manifest" path="manifest" remote="https://fuchsia.googlesource.com/manifest" revision="4c2b0da3c06341db5cebe4d02c78c93c3b2bd78b"/>
+ </projects>
+</manifest>
+''')