~wgrant/bzr-git/lp-fixes

« back to all changes in this revision

Viewing changes to tests/test_transportgit.py

  • Committer: William Grant
  • Date: 2015-05-08 02:31:10 UTC
  • Revision ID: william.grant@canonical.com-20150508023110-lvllc50nvculinow
Fix TransportObjectStore with multiple packs, and add test.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
"""Tests for bzr-git's object store."""
18
18
 
19
19
 
 
20
from dulwich.objects import Blob
20
21
from dulwich.tests.test_object_store import PackBasedObjectStoreTests
21
22
from dulwich.tests.test_refs import RefsContainerTests
 
23
from dulwich.tests.utils import make_object
22
24
 
23
25
from bzrlib.tests import TestCaseWithTransport
24
26
 
35
37
        PackBasedObjectStoreTests.tearDown(self)
36
38
        TestCaseWithTransport.tearDown(self)
37
39
 
 
40
    def test_remembers_packs(self):
 
41
        self.store.add_object(make_object(Blob, data="data"))
 
42
        self.assertEqual(0, len(self.store.packs))
 
43
        self.store.pack_loose_objects()
 
44
        self.assertEqual(1, len(self.store.packs))
 
45
 
 
46
        # Packing a second object creates a second pack.
 
47
        self.store.add_object(make_object(Blob, data="more data"))
 
48
        self.store.pack_loose_objects()
 
49
        self.assertEqual(2, len(self.store.packs))
 
50
 
 
51
        # If we reopen the store, it reloads both packs.
 
52
        restore = TransportObjectStore(self.get_transport())
 
53
        self.assertEqual(2, len(restore.packs))
 
54
 
 
55
 
38
56
# FIXME: Unfortunately RefsContainerTests requires on a specific set of refs existing.
39
57
 
40
58
# class TransportRefContainerTests(RefsContainerTests, TestCaseWithTransport):