Tatsuhisa Yamaguchi | c439ce6 | 2020-07-08 10:58:26 +0000 | [diff] [blame] | 1 | # Copyright 2020 The Chromium OS 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 | """Test fetch_cipd.""" |
| 6 | |
| 7 | from chromite.lib import cros_test_lib |
| 8 | from chromite.scripts import fetch_cipd |
| 9 | |
| 10 | |
| 11 | class FetchCipdTest(cros_test_lib.TestCase): |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame^] | 12 | """Tests for fetch_cipd script.""" |
Tatsuhisa Yamaguchi | c439ce6 | 2020-07-08 10:58:26 +0000 | [diff] [blame] | 13 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame^] | 14 | def testParseCipdUri(self): |
| 15 | uri = "cipd://chromiumos/infra/tclint/linux-amd64:abcdefghijklm" |
| 16 | path, version = fetch_cipd.ParseCipdUri(uri) |
| 17 | self.assertEqual("chromiumos/infra/tclint/linux-amd64", path) |
| 18 | self.assertEqual("abcdefghijklm", version) |
Tatsuhisa Yamaguchi | c439ce6 | 2020-07-08 10:58:26 +0000 | [diff] [blame] | 19 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame^] | 20 | def testParseCipdUriWrongScheme(self): |
| 21 | uri = "gs://chromiumos/infra/tclint/linux-amd64:abcdefghijklm" |
| 22 | with self.assertRaises(ValueError): |
| 23 | fetch_cipd.ParseCipdUri(uri) |
Tatsuhisa Yamaguchi | c439ce6 | 2020-07-08 10:58:26 +0000 | [diff] [blame] | 24 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame^] | 25 | def testParseCipdUriNoVersion(self): |
| 26 | uri = "cipd://chromiumos/infra/tclint/linux-amd64" |
| 27 | with self.assertRaises(ValueError): |
| 28 | fetch_cipd.ParseCipdUri(uri) |