/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to tests/test_git_repository.py

  • Committer: David Allouche
  • Date: 2007-12-30 01:11:44 UTC
  • mto: (0.200.47 bzr-git.pull)
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: ddaa@canonical.com-20071230011144-8o9mn507kwf265z1
GitRepository.get_inventory and .revision_tree work for the null revision. Support for testing GitRepository without disk data.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
from bzrlib.plugins.git import tests
28
28
from bzrlib.plugins.git import (
 
29
    git_dir,
29
30
    git_repository,
30
31
    ids,
31
32
    model,
32
33
    )
33
34
 
34
35
 
35
 
class TestGitRepository(tests.TestCaseInTempDir):
 
36
class TestGitRepositoryFeatures(tests.TestCaseInTempDir):
36
37
    """Feature tests for GitRepository."""
37
38
 
38
39
    _test_needs_features = [tests.GitCommandFeature]
145
146
            " u'subfile', parent_id='subdir',"
146
147
            " sha1='0ddb53cbe2dd209f550dd8d7f1287a5ed9b1ee8b', len=None))")
147
148
 
 
149
 
 
150
class MemoryGitRepository(git_repository.GitRepository):
 
151
    """A git repository without real git data on disk."""
 
152
 
 
153
    @classmethod
 
154
    def _make_model(klass, transport):
 
155
        return None
 
156
 
 
157
 
 
158
class MemoryGitDir(git_dir.GitDir):
 
159
    """A git tree with real data on disk."""
 
160
 
 
161
    _gitrepository_class = MemoryGitRepository
 
162
 
 
163
 
 
164
class MemoryGitBzrDirFormat(git_dir.GitBzrDirFormat):
 
165
    """Format for a git tree without real data on disk."""
 
166
 
 
167
    _gitdir_class = MemoryGitDir
 
168
 
 
169
 
 
170
class TestGitRepository(tests.TestCaseWithMemoryTransport):
 
171
 
 
172
    def setUp(self):
 
173
        tests.TestCaseWithMemoryTransport.setUp(self)
 
174
        self.transport = self.get_transport()
 
175
        self.transport.mkdir('.git')
 
176
        self.git_dir = MemoryGitBzrDirFormat().open(self.transport)
 
177
        self.git_repo = self.git_dir.open_repository()
 
178
 
148
179
    def test_supports_rich_root(self):
149
180
        # GitRepository.supports_rich_root is False, at least for now.
150
 
        tests.run_git('init')
151
 
        repo = repository.Repository.open('.')
 
181
        repo = self.git_repo
152
182
        self.assertEqual(repo.supports_rich_root(), False)
153
183
 
 
184
    def assertIsNullInventory(self, inv):
 
185
        self.assertEqual(inv.root, None)
 
186
        self.assertEqual(inv.revision_id, revision.NULL_REVISION)
 
187
        self.assertEqual(list(inv.iter_entries()), [])
 
188
 
 
189
    def test_get_inventory_none(self):
 
190
        # GitRepository.get_inventory(None) returns the null inventory.
 
191
        repo = self.git_repo
 
192
        inv = repo.get_inventory(None)
 
193
        self.assertIsNullInventory(inv)
 
194
 
 
195
    def test_revision_tree_none(self):
 
196
        # GitRepository.revision_tree(None) returns the null tree.
 
197
        repo = self.git_repo
 
198
        tree = repo.revision_tree(None)
 
199
        self.assertEqual(tree.get_revision_id(), revision.NULL_REVISION)
 
200
        self.assertIsNullInventory(tree.inventory)
 
201
 
154
202
 
155
203
class TestGitRepositoryParseRev(tests.TestCase):
156
204
    """Unit tests for GitRepository._parse_rev."""