blob: 76eb4cbe8dc482c6f748bd58b4077bedb0c21739 [file] [log] [blame]
Kuang-che Wu6e4beca2018-06-27 17:45:02 +08001# -*- coding: utf-8 -*-
Kuang-che Wue41e0062017-09-01 19:04:14 +08002# 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
7from __future__ import print_function
8import unittest
9
Kuang-che Wua5723492019-11-25 20:59:34 +080010try:
11 from unittest import mock
12except ImportError:
13 # TODO(kcwu): remove once migrated to python3
14 import mock
Kuang-che Wue41e0062017-09-01 19:04:14 +080015
16import switch_git
17
18
19@mock.patch('bisect_kit.common.config_logging', mock.Mock())
20class TestSwitchGit(unittest.TestCase):
21 """Test switch_git.py."""
22
23 def test_main(self):
24 with mock.patch('bisect_kit.cli.argtype_dir_path', lambda x: x):
25 with mock.patch('bisect_kit.git_util.checkout_version') as mock_func:
26 git_repo = '/path/to/git/repo'
27 rev = '123456789'
28 switch_git.main(['--git_repo', git_repo, rev])
29
30 mock_func.assert_called_with(git_repo, rev)
31
32
33if __name__ == '__main__':
34 unittest.main()