Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Unified Diff: unittests/package_test.py

Issue 2779683005: [package.proto] convert deps from list to map. (Closed)
Patch Set: fixit Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « recipe_engine/package_pb2.py ('k') | unittests/repo_test_util.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: unittests/package_test.py
diff --git a/unittests/package_test.py b/unittests/package_test.py
index 5b070ecc178b800925227dd92aac82e1aa6571f7..bc1d26c8daea8864741806d139b1c7b7ca5a9a07 100755
--- a/unittests/package_test.py
+++ b/unittests/package_test.py
@@ -12,8 +12,9 @@ import unittest
import repo_test_util
import mock
-from recipe_engine import package
+from recipe_engine import fetch
+from recipe_engine import package
TEST_AUTHOR = 'foo@example.com'
@@ -382,21 +383,19 @@ class TestPackageSpec(MockIOThings, unittest.TestCase):
self.proto_text = '\n'.join([
'{',
- ' "api_version": 1,',
- ' "deps": [',
- ' {',
+ ' "api_version": 2,',
+ ' "deps": {',
+ ' "bar": {',
' "branch": "superbar",',
- ' "project_id": "bar",',
' "revision": "deadd00d",',
' "url": "https://repo.com/bar.git"',
' },',
- ' {',
+ ' "foo": {',
' "branch": "master",',
- ' "project_id": "foo",',
' "revision": "cafebeef",',
' "url": "https://repo.com/foo.git"',
' }',
- ' ],',
+ ' },',
' "project_id": "super_main_package",',
' "recipes_path": "path/to/recipes"',
'}',
@@ -434,6 +433,42 @@ class TestPackageSpec(MockIOThings, unittest.TestCase):
with self.assertRaises(AssertionError):
package.PackageSpec.load_proto(proto_file)
+ def test_old_deps(self):
+ proto_text = '\n'.join([
+ '{',
+ ' "api_version": 1,',
+ ' "deps": [',
+ ' {',
+ ' "branch": "superbar",',
+ ' "project_id": "bar",',
+ ' "revision": "deadd00d",',
+ ' "url": "https://repo.com/bar.git"',
+ ' },',
+ ' {',
+ ' "branch": "master",',
+ ' "project_id": "foo",',
+ ' "revision": "cafebeef",',
+ ' "url": "https://repo.com/foo.git"',
+ ' }',
+ ' ],',
+ ' "project_id": "super_main_package",',
+ ' "recipes_path": "path/to/recipes"',
+ '}',
+ ])
+ proto_file = MockProtoFile('repo/root/infra/config/recipes.cfg', proto_text)
+
+ spec = package.PackageSpec.load_proto(proto_file)
+ self.assertEqual(spec.deps['foo'], package.GitRepoSpec(
+ 'foo',
+ 'https://repo.com/foo.git',
+ 'master',
+ 'cafebeef',
+ '',
+ fetch.GitBackend()
+ ))
+ self.assertEqual(proto_file.to_raw(spec.dump()), proto_text)
+
+
def test_unsupported_version(self):
proto_text = """{
"api_version": 99999999,
« no previous file with comments | « recipe_engine/package_pb2.py ('k') | unittests/repo_test_util.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698