Browse Source

[gerrit_client] Fix test to not hit real gerrit service.

There may be other tests which aren't correct though, this is just
the one I saw during presubmit.

R=aravindvasudev@google.com

Bug: 330347045
Change-Id: I6499b5103bf15c30f5e8a2fdcd7abeba094a39d7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5394357
Auto-Submit: Robbie Iannucci <iannucci@chromium.org>
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
Robert Iannucci 1 year ago
parent
commit
b6f459b87c
1 changed files with 6 additions and 3 deletions
  1. 6 3
      tests/gerrit_client_test.py

+ 6 - 3
tests/gerrit_client_test.py

@@ -27,13 +27,16 @@ class TestGerritClient(unittest.TestCase):
                                           'branchname')
 
     @mock.patch('gerrit_util.CreateGerritBranch', return_value='')
-    def test_branch(self, util_mock):
+    @mock.patch('gerrit_util.GetGerritBranch', return_value='')
+    def test_branch(self, _, CreateGerritBranch_mock):
         gerrit_client.main([
             'branch', '--host', 'https://example.org/foo', '--project',
             'projectname', '--branch', 'branchname', '--commit', 'commitname'
         ])
-        util_mock.assert_called_once_with('example.org', 'projectname',
-                                          'branchname', 'commitname')
+        CreateGerritBranch_mock.assert_called_once_with('example.org',
+                                                        'projectname',
+                                                        'branchname',
+                                                        'commitname')
 
     @mock.patch('gerrit_util.QueryChanges', return_value='')
     def test_changes(self, util_mock):