/breezy/trunk

To get this branch, use:
bzr branch https://code.breezy-vcs.org/breezy/trunk

« back to all changes in this revision

Viewing changes to breezy/git/tests/test_object_store.py

  • Committer: Breezy landing bot
  • Author(s): Vincent Ladeuil
  • Date: 2019-03-06 14:58:32 UTC
  • mfrom: (7294.1.2 trunk)
  • Revision ID: breezy.the.bot@gmail.com-20190306145832-ghgjxu1recloriwh
Open trunk again as 3.1.0dev1

Merged from https://code.launchpad.net/~vila/brz/trunk/+merge/364041

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
from __future__ import absolute_import
20
20
 
 
21
import os
 
22
import shutil
 
23
 
21
24
from dulwich.objects import (
22
25
    Blob,
23
26
    Tree,
144
147
    def setUp(self):
145
148
        super(BazaarObjectStoreTests, self).setUp()
146
149
        self.branch = self.make_branch(".")
147
 
        self.branch.lock_write()
148
 
        self.addCleanup(self.branch.unlock)
149
150
        self.store = BazaarObjectStore(self.branch.repository)
150
151
 
151
152
    def test_get_blob(self):
 
153
        self.branch.lock_write()
 
154
        self.addCleanup(self.branch.unlock)
152
155
        b = Blob()
153
156
        b.data = b'a\nb\nc\nd\ne\n'
154
157
        self.store.lock_read()
167
170
        self.store.lock_read()
168
171
        self.assertEqual(b, self.store[b.id])
169
172
 
 
173
    def test_directory_converted_to_symlink(self):
 
174
        b = Blob()
 
175
        b.data = b'trgt'
 
176
        self.store.lock_read()
 
177
        self.addCleanup(self.store.unlock)
 
178
        self.assertRaises(KeyError, self.store.__getitem__, b.id)
 
179
        tree = self.branch.controldir.create_workingtree()
 
180
        self.build_tree_contents([
 
181
            ('foo/', ),
 
182
            ('foo/bar', b'a\nb\nc\nd\ne\n')])
 
183
        tree.add(['foo', 'foo/bar'])
 
184
        revid1 = tree.commit('commit 1')
 
185
        shutil.rmtree('foo')
 
186
        os.symlink('trgt', 'foo')
 
187
        revid2 = tree.commit('commit 2')
 
188
        # read locks cache
 
189
        self.assertRaises(KeyError, self.store.__getitem__, b.id)
 
190
        self.store.unlock()
 
191
        self.store.lock_read()
 
192
        self.assertEqual(b, self.store[b.id])
 
193
 
170
194
    def test_get_raw(self):
 
195
        self.branch.lock_write()
 
196
        self.addCleanup(self.branch.unlock)
171
197
        b = Blob()
172
198
        b.data = b'a\nb\nc\nd\ne\n'
173
199
        self.store.lock_read()
187
213
        self.assertEqual(b.as_raw_string(), self.store.get_raw(b.id)[1])
188
214
 
189
215
    def test_contains(self):
 
216
        self.branch.lock_write()
 
217
        self.addCleanup(self.branch.unlock)
190
218
        b = Blob()
191
219
        b.data = b'a\nb\nc\nd\ne\n'
192
220
        self.store.lock_read()