Kuang-che Wu | 6e4beca | 2018-06-27 17:45:02 +0800 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- |
Kuang-che Wu | e41e006 | 2017-09-01 19:04:14 +0800 | [diff] [blame] | 2 | # Copyright 2017 The Chromium OS 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 | """Test switch_git script.""" |
| 6 | |
| 7 | from __future__ import print_function |
| 8 | import unittest |
Kuang-che Wu | 23192ad | 2020-03-11 18:12:46 +0800 | [diff] [blame] | 9 | from unittest import mock |
Kuang-che Wu | e41e006 | 2017-09-01 19:04:14 +0800 | [diff] [blame] | 10 | |
| 11 | import switch_git |
| 12 | |
| 13 | |
| 14 | @mock.patch('bisect_kit.common.config_logging', mock.Mock()) |
| 15 | class TestSwitchGit(unittest.TestCase): |
| 16 | """Test switch_git.py.""" |
| 17 | |
| 18 | def test_main(self): |
| 19 | with mock.patch('bisect_kit.cli.argtype_dir_path', lambda x: x): |
| 20 | with mock.patch('bisect_kit.git_util.checkout_version') as mock_func: |
| 21 | git_repo = '/path/to/git/repo' |
| 22 | rev = '123456789' |
| 23 | switch_git.main(['--git_repo', git_repo, rev]) |
| 24 | |
| 25 | mock_func.assert_called_with(git_repo, rev) |
| 26 | |
| 27 | |
| 28 | if __name__ == '__main__': |
| 29 | unittest.main() |