[git_auth] Move gitcookies to free backup name

Bug: 410576093
Change-Id: Ib2d9db97f4e4e1e8cfe1914ba7ffb881f9e16bbf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6453918
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Yiwei Zhang <yiwzhang@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
This commit is contained in:
Allen Li
2025-04-15 14:54:46 -07:00
committed by LUCI CQ
parent 9d75b76ca5
commit d28539d200
2 changed files with 19 additions and 4 deletions

View File

@@ -362,6 +362,21 @@ class TestConfigWizard(unittest.TestCase):
)
self.assertEqual(got, want)
def test_move_file(self):
with tempfile.TemporaryDirectory() as d:
path = os.path.join(d, 'foo')
open(path, 'w').close()
self.wizard._move_file(path)
self.assertEqual(os.listdir(d), ['foo.bak'])
def test_move_file_backup_exists(self):
with tempfile.TemporaryDirectory() as d:
path = os.path.join(d, 'foo')
open(path, 'w').close()
open(os.path.join(d, 'foo.bak'), 'w').close()
self.wizard._move_file(path)
self.assertEqual(sorted(os.listdir(d)), ['foo.bak', 'foo.bak2'])
class _FakeUI(object):
"""Implements UserInterface for testing."""