/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.200.1087 by Jelmer Vernooij
Add basic tests for GitRevisions.
1
# Copyright (C) 2011 Canonical Ltd
2
# Authors: Jelmer Vernooij <jelmer@canonical.com>
3
#
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 2 of the License, or
7
# (at your option) any later version.
8
#
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.
13
#
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
18
"""Tests for git-like versioned files."""
19
20
from dulwich.repo import Repo as GitRepo
21
22
from bzrlib.repository import Repository
23
from bzrlib.tests import TestCaseInTempDir
24
25
from bzrlib.plugins.git import tests
26
27
class GitRevisionsTests(TestCaseInTempDir):
28
29
    def setUp(self):
30
        super(GitRevisionsTests, self).setUp()
31
        self.gitrepo = GitRepo.init(self.test_dir)
32
        self.revisions = Repository.open(self.test_dir).revisions
33
34
    def _do_commit(self):
35
        builder = tests.GitBranchBuilder()
36
        builder.set_file('a', 'text for a\n', False)
37
        commit_handle = builder.commit('Joe Foo <joe@foo.com>', u'message')
38
        mapping = builder.finish()
39
        return mapping[commit_handle]
40
41
    def test_empty(self):
42
        self.assertEquals([], self.revisions.keys())
43
44
    def test_check(self):
45
        # Just a no-op at the moment
46
        self.assertTrue(self.revisions.check())
47
48
    def test_revision(self):
49
        gitsha = self._do_commit()
50
        self.assertEquals([(gitsha,)], self.revisions.keys())