OLD | NEW |
| (Empty) |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | |
2 # Use of this source code is governed by a BSD-style license that can be | |
3 # found in the LICENSE file. | |
4 | |
5 import unittest | |
6 from infra_libs.event_mon import checkouts | |
7 | |
8 | |
9 class TestParseRevInfo(unittest.TestCase): | |
10 def test_empty_file(self): | |
11 self.assertEqual(checkouts.parse_revinfo(''), {}) | |
12 | |
13 def test_one_checkout(self): | |
14 self.assertEqual(checkouts.parse_revinfo('a: b@c'), | |
15 {'a': {'source_url': 'b', 'revision': 'c'}}) | |
16 | |
17 def test_multiple_checkouts(self): | |
18 self.assertEqual(checkouts.parse_revinfo('c: d@e\nf: g@h'), | |
19 {'c': {'source_url': 'd', 'revision': 'e'}, | |
20 'f': {'source_url': 'g', 'revision': 'h'}}) | |
21 | |
22 def test_missing_revision(self): | |
23 self.assertEqual(checkouts.parse_revinfo('i: j'), | |
24 {'i': {'source_url': 'j', 'revision': None}}) | |
25 | |
26 def test_on_actual_output(self): | |
27 # pylint: disable=line-too-long | |
28 output = """build: https://chromium.googlesource.com/chromium/tools/build.gi
t@553752662e0dd4e135e6956d3f8aa9a02c3c1407 | |
29 build/scripts/gsd_generate_index: svn://svn.chromium.org/chrome/trunk/tools/gsd_
generate_index@293875 | |
30 build/scripts/private/data/reliability: svn://svn.chromium.org/chrome/trunk/src/
chrome/test/data/reliability@293875 | |
31 build/scripts/tools/deps2git: svn://svn.chromium.org/chrome/trunk/tools/deps2git
@293875 | |
32 build/third_party/gsutil: svn://svn.chromium.org/gsutil/trunk/src@263 | |
33 build/third_party/gsutil/boto: svn://svn.chromium.org/boto@7 | |
34 build/third_party/lighttpd: svn://svn.chromium.org/chrome/trunk/deps/third_party
/lighttpd@58968 | |
35 build/third_party/xvfb: svn://svn.chromium.org/chrome/trunk/tools/third_party/xv
fb@293875 | |
36 depot_tools: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@293875 | |
37 expect_tests: https://chromium.googlesource.com/infra/testing/expect_tests.git@7
a0649eb4fcfdf05ebfaffbc33752122a88d72f7 | |
38 infra: https://chromium.googlesource.com/infra/infra.git@5e86c081d415509716a0ce1
aa7a62b915b59aa03 | |
39 infra/appengine/swarming: https://chromium.googlesource.com/infra/swarming.git@7
a831b64ebff96260756e353ab002644d7c3abb6 | |
40 infra/appengine/third_party/bootstrap: https://chromium.googlesource.com/infra/t
hird_party/bootstrap.git@b4895a0d6dc493f17fe9092db4debe44182d42ac | |
41 infra/appengine/third_party/cloudstorage: https://chromium.googlesource.com/infr
a/third_party/cloudstorage.git@ad74316d12e198e0c7352bd666bbc2ec7938bd65 | |
42 infra/appengine/third_party/endpoints-proto-datastore: https://chromium.googleso
urce.com/infra/third_party/endpoints-proto-datastore.git@971bca8e31a4ab0ec78b823
add5a47394d78965a | |
43 infra/appengine/third_party/google-api-python-client: https://chromium.googlesou
rce.com/external/github.com/google/google-api-python-client.git@49d45a6c3318b75e
551c3022020f46c78655f365 | |
44 infra/appengine/third_party/highlight: https://chromium.googlesource.com/infra/t
hird_party/highlight.js.git@fa5bfec38aebd1415a81c9c674d0fde8ee5ef0ba | |
45 infra/appengine/third_party/npm_modules: https://chromium.googlesource.com/infra
/third_party/npm_modules.git@f3f825ae2d3521d889fe076bd2229f6a1fadaac6 | |
46 infra/appengine/third_party/pipeline: https://chromium.googlesource.com/infra/th
ird_party/appengine-pipeline.git@e79945156a7a3a48eecb29b792a9b7925631aadf | |
47 infra/appengine/third_party/src/github.com/golang/oauth2: https://github.com/gol
ang/oauth2.git@cb029f4c1f58850787981eefaf9d9bf547c1a722 | |
48 infra/appengine/third_party/trace-viewer: https://chromium.googlesource.com/exte
rnal/trace-viewer.git@76a4496033c164d8be9ee8c57f702b0859cb1911 | |
49 infra/bootstrap/virtualenv: https://github.com/pypa/virtualenv.git@93cfa83481a1c
b934eb14c946d33aef94c21bcb0 | |
50 testing_support: https://chromium.googlesource.com/infra/testing/testing_support
.git@134e350cb5c6bfc14e8b8d0f0f0508ffc769d3bb | |
51 """ | |
52 revinfo = checkouts.parse_revinfo(output) | |
53 # Check some invariants | |
54 self.assertTrue(len(revinfo) > 0, 'revinfo should contain values') | |
55 for v in revinfo.itervalues(): | |
56 self.assertEqual(len(v), 2) | |
57 self.assertIn('://', v['source_url'], | |
58 msg='"://" not in url string. Got %s' % v['source_url']) | |
59 self.assertIn(v['source_url'].split('://')[0], ('https', 'svn')) | |
OLD | NEW |