Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Unified Diff: infra/libs/git2/test/commit_test.py

Issue 413983003: Refactor infra git libs and testing. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Address comments Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: infra/libs/git2/test/commit_test.py
diff --git a/infra/libs/git2/test/commit_test.py b/infra/libs/git2/test/commit_test.py
new file mode 100644
index 0000000000000000000000000000000000000000..e7c23f149d7d25427c9addd124d26f2b7fa087cf
--- /dev/null
+++ b/infra/libs/git2/test/commit_test.py
@@ -0,0 +1,56 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+from infra.libs import git2
+from infra.libs.git2.test import test_util
+
+
+class TestCommit(test_util.TestBasis):
+ def testComparison(self):
+ r = self.mkRepo()
+ c = r['refs/heads/branch_O'].commit
+ self.assertEqual(c, c)
+ self.assertEqual(c, r['refs/heads/branch_O'].commit)
+ self.assertNotEqual(c, r['refs/heads/branch_S'].commit)
+ self.assertIs(c.repo, r)
+
+ def testRepr(self):
+ r = self.mkRepo()
+ c = r['refs/heads/branch_O'].commit
+ self.assertEqual("Commit(%r, %r)" % (r, self.repo['O']), repr(c))
+
+ def testData(self):
+ r = self.mkRepo()
+ d = r['refs/heads/branch_O'].commit.data
+ self.assertEqual(d.committer.email, 'commitish@example.com')
+
+ def testBogus(self):
+ r = self.mkRepo()
+ d = git2.Commit(r, 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeef').data
+ self.assertIs(d, git2.INVALID)
+ self.assertIs(d.committer, git2.INVALID)
+ self.assertIs(d.committer.alter(user='tom'), git2.INVALID)
+
+ def testParent(self):
+ r = self.mkRepo()
+ c = r['refs/heads/branch_O'].commit
+ self.assertEqual(c.parent.hsh, self.repo['N'])
+
+ a = r['refs/heads/root_A'].commit
+ self.assertIsNone(a.parent)
+
+ z = r['refs/heads/branch_Z'].commit
+ self.assertIs(z.parent, git2.INVALID)
+
+ def testAlter(self):
+ r = self.mkRepo()
+ c = r['refs/heads/branch_O'].commit
+ d = c.data
+
+ a = c.alter(committer=d.committer.alter(email='bob@dude.example.com'))
+ self.assertEqual(a.hsh, 'fadfbe63d40f60f5313a71a1c9d72a741ee91770')
+
+ with self.assertRaises(Exception):
+ c.alter(tree='failbeef')
+

Powered by Google App Engine
This is Rietveld 408576698