git_command: switch version caches to functools

Simplifies the code a bit to use the stdlib cache helper.

Change-Id: I778e90100ce748a71cc3a5a5d67dda403334315e
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/305482
Reviewed-by: Raman Tenneti <rtenneti@google.com>
Tested-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
Mike Frysinger
2021-05-06 00:28:32 -04:00
parent 2f8fdbecde
commit 8e768eaaa7
2 changed files with 20 additions and 21 deletions

View File

@ -29,8 +29,8 @@ import wrapper
class SSHUnitTest(unittest.TestCase):
"""Tests the ssh functions."""
def test_ssh_version(self):
"""Check ssh_version() handling."""
def test_parse_ssh_version(self):
"""Check parse_ssh_version() handling."""
ver = git_command._parse_ssh_version('Unknown\n')
self.assertEqual(ver, ())
ver = git_command._parse_ssh_version('OpenSSH_1.0\n')
@ -40,6 +40,11 @@ class SSHUnitTest(unittest.TestCase):
ver = git_command._parse_ssh_version('OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n 7 Dec 2017\n')
self.assertEqual(ver, (7, 6))
def test_ssh_version(self):
"""Check ssh_version() handling."""
with mock.patch('git_command._run_ssh_version', return_value='OpenSSH_1.2\n'):
self.assertEqual(git_command.ssh_version(), (1, 2))
def test_ssh_sock(self):
"""Check ssh_sock() function."""
with mock.patch('tempfile.mkdtemp', return_value='/tmp/foo'):