From deff57f9b2c816e47aa6a94edaf019e244adff63 Mon Sep 17 00:00:00 2001 From: Josip Sokcevic Date: Wed, 4 Nov 2020 19:36:42 +0000 Subject: [PATCH] Add unit tests for guessing main as upstream R=ehmaldonado@chromium.org Bug: 1143724 Change-Id: I69ce296a27b36c1073999f2b3c51421ac94e7ef2 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2519254 Commit-Queue: Josip Sokcevic Reviewed-by: Edward Lesmes --- tests/scm_unittest.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/scm_unittest.py b/tests/scm_unittest.py index 5584d5911b..130e4f16b7 100755 --- a/tests/scm_unittest.py +++ b/tests/scm_unittest.py @@ -185,6 +185,12 @@ class RealGitTest(fake_repos.FakeReposTestBase): self.assertEqual( ('origin', 'refs/heads/master'), scm.GIT.FetchUpstreamTuple(self.cwd)) + @mock.patch('scm.GIT.GetRemoteBranches', + return_value=['origin/master', 'origin/main']) + def testFetchUpstreamTuple_GuessOriginMain(self, _mockGetRemoteBranches): + self.assertEqual(('origin', 'refs/heads/main'), + scm.GIT.FetchUpstreamTuple(self.cwd)) + def testFetchUpstreamTuple_RietveldUpstreamConfig(self): scm.GIT.SetConfig(self.cwd, 'rietveld.upstream-branch', 'rietveld-upstream') scm.GIT.SetConfig(self.cwd, 'rietveld.upstream-remote', 'rietveld-remote')