2 # Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2010
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 from buildfarm.history import GitBranch
20 from dulwich.repo import Repo
23 from testtools import TestCase
26 class GitBranchTests(TestCase):
29 super(GitBranchTests, self).setUp()
30 self.repo = Repo.init(tempfile.mkdtemp())
32 def test_log_empty(self):
33 branch = GitBranch(self.repo.path, "master")
34 self.assertEquals([], list(branch.log()))
36 def test_log_commits(self):
37 branch = GitBranch(self.repo.path, "master")
38 self.repo.do_commit("message", committer="Jelmer Vernooij")
39 log = list(branch.log())
40 self.assertEquals(1, len(log))
41 self.assertEquals("message", log[0].message)
43 def test_empty_diff(self):
44 branch = GitBranch(self.repo.path, "master")
45 revid = self.repo.do_commit("message", committer="Jelmer Vernooij")
46 entry, diff = list(branch.diff(revid))
47 self.assertEquals("message", entry.message)
48 self.assertEquals("", diff)