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

Side by Side 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, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « git_cache.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """Unit tests for git_cache.py"""
7
8 import os
9 import shutil
10 import sys
11 import tempfile
12 import unittest
13
14 DEPOT_TOOLS_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
15 sys.path.insert(0, DEPOT_TOOLS_ROOT)
16
17 from testing_support import coverage_utils
18 import git_cache
19
20 class GitCacheTest(unittest.TestCase):
21 @classmethod
22 def setUpClass(cls):
23 cls.cache_dir = tempfile.mkdtemp(prefix='git_cache_test_')
24 git_cache.Mirror.SetCachePath(cls.cache_dir)
25
26 @classmethod
27 def tearDownClass(cls):
28 shutil.rmtree(cls.cache_dir, ignore_errors=True)
29
30 def testParseFetchSpec(self):
31 testData = [
32 ([], []),
33 (['master'], [('+refs/heads/master:refs/heads/master',
34 r'\+refs/heads/master:.*')]),
35 (['master/'], [('+refs/heads/master:refs/heads/master',
36 r'\+refs/heads/master:.*')]),
37 (['+master'], [('+refs/heads/master:refs/heads/master',
38 r'\+refs/heads/master:.*')]),
39 (['refs/heads/*'], [('+refs/heads/*:refs/heads/*',
40 r'\+refs/heads/\*:.*')]),
41 (['foo/bar/*', 'baz'], [('+refs/heads/foo/bar/*:refs/heads/foo/bar/*',
42 r'\+refs/heads/foo/bar/\*:.*'),
43 ('+refs/heads/baz:refs/heads/baz',
44 r'\+refs/heads/baz:.*')]),
45 (['refs/foo/*:refs/bar/*'], [('+refs/foo/*:refs/bar/*',
46 r'\+refs/foo/\*:.*')])
47 ]
48
49 mirror = git_cache.Mirror('test://phony.example.biz')
50 for fetch_specs, expected in testData:
51 mirror = git_cache.Mirror('test://phony.example.biz', refs=fetch_specs)
52 self.assertItemsEqual(mirror.fetch_specs, expected)
53
54 if __name__ == '__main__':
55 sys.exit(coverage_utils.covered_main((
56 os.path.join(DEPOT_TOOLS_ROOT, 'git_cache.py')
57 ), required_percentage=0))
OLDNEW
« 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