113
def test_chk_bytes_are_fully_buffered(self):
114
repo = self.make_repository('.')
116
self.addCleanup(repo.unlock)
117
repo.start_write_group()
119
sha1, len, _ = repo.chk_bytes.add_lines((None,),
120
None, ["foo\n", "bar\n"], random_id=True)
121
self.assertEqual('4e48e2c9a3d2ca8a708cb0cc545700544efb5021',
124
set([('sha1:4e48e2c9a3d2ca8a708cb0cc545700544efb5021',)]),
125
repo.chk_bytes.keys())
127
repo.abort_write_group()
130
repo.commit_write_group()
131
# This may not always be correct if we change away from BTreeGraphIndex
132
# in the future. But for now, lets check that chk_bytes are fully
134
index = repo.chk_bytes._index._graph_index._indices[0]
135
self.assertIsInstance(index, btree_index.BTreeGraphIndex)
136
self.assertIs(type(index._leaf_node_cache), dict)
137
# Re-opening the repository should also have a repo with everything
139
repo2 = repository.Repository.open(self.get_url())
141
self.addCleanup(repo2.unlock)
142
index = repo2.chk_bytes._index._graph_index._indices[0]
143
self.assertIsInstance(index, btree_index.BTreeGraphIndex)
144
self.assertIs(type(index._leaf_node_cache), dict)
112
147
class TestCommitWriteGroupIntegrityCheck(TestCaseWithRepositoryCHK):
113
148
"""Tests that commit_write_group prevents various kinds of invalid data