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

Unified Diff: tests/git_cache_test.py

Issue 1320383004: Allow 'git cache fetch' to re-bootstrap. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Added warning in _preserve_fetchspec Created 5 years, 3 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 | « git_cache.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/git_cache_test.py
diff --git a/tests/git_cache_test.py b/tests/git_cache_test.py
new file mode 100755
index 0000000000000000000000000000000000000000..55ea1269de0230f059545744116346414dad2c61
--- /dev/null
+++ b/tests/git_cache_test.py
@@ -0,0 +1,57 @@
+#!/usr/bin/env python
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Unit tests for git_cache.py"""
+
+import os
+import shutil
+import sys
+import tempfile
+import unittest
+
+DEPOT_TOOLS_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+sys.path.insert(0, DEPOT_TOOLS_ROOT)
+
+from testing_support import coverage_utils
+import git_cache
+
+class GitCacheTest(unittest.TestCase):
+ @classmethod
+ def setUpClass(cls):
+ cls.cache_dir = tempfile.mkdtemp(prefix='git_cache_test_')
+ git_cache.Mirror.SetCachePath(cls.cache_dir)
+
+ @classmethod
+ def tearDownClass(cls):
+ shutil.rmtree(cls.cache_dir, ignore_errors=True)
+
+ def testParseFetchSpec(self):
+ testData = [
+ ([], []),
+ (['master'], [('+refs/heads/master:refs/heads/master',
+ r'\+refs/heads/master:.*')]),
+ (['master/'], [('+refs/heads/master:refs/heads/master',
+ r'\+refs/heads/master:.*')]),
+ (['+master'], [('+refs/heads/master:refs/heads/master',
+ r'\+refs/heads/master:.*')]),
+ (['refs/heads/*'], [('+refs/heads/*:refs/heads/*',
+ r'\+refs/heads/\*:.*')]),
+ (['foo/bar/*', 'baz'], [('+refs/heads/foo/bar/*:refs/heads/foo/bar/*',
+ r'\+refs/heads/foo/bar/\*:.*'),
+ ('+refs/heads/baz:refs/heads/baz',
+ r'\+refs/heads/baz:.*')]),
+ (['refs/foo/*:refs/bar/*'], [('+refs/foo/*:refs/bar/*',
+ r'\+refs/foo/\*:.*')])
+ ]
+
+ mirror = git_cache.Mirror('test://phony.example.biz')
+ for fetch_specs, expected in testData:
+ mirror = git_cache.Mirror('test://phony.example.biz', refs=fetch_specs)
+ self.assertItemsEqual(mirror.fetch_specs, expected)
+
+if __name__ == '__main__':
+ sys.exit(coverage_utils.covered_main((
+ os.path.join(DEPOT_TOOLS_ROOT, 'git_cache.py')
+ ), required_percentage=0))
« no previous file with comments | « git_cache.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698