Gerrit git cl: add description cache handling regression test.
Follow up on https://chromium-review.googlesource.com/#/c/439877/
which fixed a bug.
R=kbr@chromium.org
BUG=688765
Change-Id: I8cfc5feb2d8060182572b2d4ecb6a038bf1e0abf
Reviewed-on: https://chromium-review.googlesource.com/443350
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Commit-Queue: Andrii Shyshkalov <tandrii@chromium.org>
diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py
index d4be5b9..a2e3733 100755
--- a/tests/git_cl_test.py
+++ b/tests/git_cl_test.py
@@ -2854,6 +2854,26 @@
self.assertEqual(cl._GetChangeDetail(options=['A'], no_cache=True), 'a')
self.assertEqual(cl._GetChangeDetail(options=['B']), 'b')
+ def test_gerrit_description_caching(self):
+ def gen_detail(rev, desc):
+ return {
+ 'current_revision': rev,
+ 'revisions': {rev: {'commit': {'message': desc}}}
+ }
+ self.calls = [
+ (('GetChangeDetail', 'host', '1',
+ ['CURRENT_REVISION', 'CURRENT_COMMIT']),
+ gen_detail('rev1', 'desc1')),
+ (('GetChangeDetail', 'host', '1',
+ ['CURRENT_REVISION', 'CURRENT_COMMIT']),
+ gen_detail('rev2', 'desc2')),
+ ]
+
+ self._mock_gerrit_changes_for_detail_cache()
+ cl = git_cl.Changelist(issue=1, codereview='gerrit')
+ self.assertEqual(cl.GetDescription(), 'desc1')
+ self.assertEqual(cl.GetDescription(), 'desc1') # cache hit.
+ self.assertEqual(cl.GetDescription(force=True), 'desc2')
if __name__ == '__main__':
logging.basicConfig(