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 <sokcevic@google.com>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
diff --git a/tests/scm_unittest.py b/tests/scm_unittest.py
index 5584d59..130e4f1 100755
--- a/tests/scm_unittest.py
+++ b/tests/scm_unittest.py
@@ -185,6 +185,12 @@
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')