blob: 928eb402fc75cc9b65b977d71617e01037099e34 [file] [log] [blame]
Mike Frysingerca540ae2019-07-10 15:42:30 -04001# -*- coding:utf-8 -*-
2#
3# Copyright 2019 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
Mike Frysinger87deaef2019-07-26 21:14:55 -040017"""Unittests for the git_command.py module."""
18
19from __future__ import print_function
20
Mike Frysingerca540ae2019-07-10 15:42:30 -040021import unittest
22
23import git_command
24
25
26class GitCallUnitTest(unittest.TestCase):
27 """Tests the _GitCall class (via git_command.git)."""
28
29 def test_version_tuple(self):
30 """Check git.version_tuple() handling."""
31 ver = git_command.git.version_tuple()
32 self.assertIsNotNone(ver)
33
34 # We don't dive too deep into the values here to avoid having to update
35 # whenever git versions change. We do check relative to this min version
36 # as this is what `repo` itself requires via MIN_GIT_VERSION.
37 MIN_GIT_VERSION = (1, 7, 2)
38 self.assertTrue(isinstance(ver.major, int))
39 self.assertTrue(isinstance(ver.minor, int))
40 self.assertTrue(isinstance(ver.micro, int))
41
42 self.assertGreater(ver.major, MIN_GIT_VERSION[0] - 1)
43 self.assertGreaterEqual(ver.micro, 0)
44 self.assertGreaterEqual(ver.major, 0)
45
46 self.assertGreaterEqual(ver, MIN_GIT_VERSION)
47 self.assertLess(ver, (9999, 9999, 9999))
48
49 self.assertNotEqual('', ver.full)