1
# Copyright (C) 2010 Jelmer Vernooij <jelmer@samba.org>
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
"""Tests for bzr-git's object store."""
19
from dulwich.objects import (
23
from bzrlib.graph import (
26
from bzrlib.tests import (
30
from bzrlib.plugins.git.object_store import (
32
_find_missing_bzr_revids,
36
class ExpectedShaTests(TestCase):
39
super(ExpectedShaTests, self).setUp()
44
_check_expected_sha(None, self.obj)
47
_check_expected_sha(self.obj.sha().hexdigest(), self.obj)
48
self.assertRaises(AssertionError, _check_expected_sha,
51
def test_binary(self):
52
_check_expected_sha(self.obj.sha().digest(), self.obj)
53
self.assertRaises(AssertionError, _check_expected_sha,
57
class FindMissingBzrRevidsTests(TestCase):
59
def _find_missing(self, ancestry, want, have):
60
return _find_missing_bzr_revids(
61
DictParentsProvider(ancestry).get_parent_map,
64
def test_simple(self):
65
self.assertEquals(set(), self._find_missing({}, [], []))
67
def test_up_to_date(self):
68
self.assertEquals(set(),
69
self._find_missing({"a": ["b"]}, ["a"], ["a"]))
71
def test_one_missing(self):
72
self.assertEquals(set(["a"]),
73
self._find_missing({"a": ["b"]}, ["a"], ["b"]))
75
def test_two_missing(self):
76
self.assertEquals(set(["a", "b"]),
77
self._find_missing({"a": ["b"], "b": ["c"]}, ["a"], ["c"]))
79
def test_two_missing_history(self):
80
self.assertEquals(set(["a", "b"]),
81
self._find_missing({"a": ["b"], "b": ["c"], "c": ["d"]},