173
173
"key\x00\x00\t\x00data\n"
176
def test_clear_cache(self):
177
builder = GraphIndexBuilder(reference_lists=2)
178
# This is a no-op, but the api should exist
179
builder.clear_cache()
176
181
def test_node_references_are_byte_offsets(self):
177
182
builder = GraphIndexBuilder(reference_lists=1)
178
183
builder.add_node(('reference', ), 'data', ([], ))
383
388
size = trans.put_file('index', stream)
384
389
return GraphIndex(trans, 'index', size)
391
def test_clear_cache(self):
392
index = self.make_index()
393
# For now, we just want to make sure the api is available. As this is
394
# old code, we don't really worry if it *does* anything.
386
397
def test_open_bad_index_no_error(self):
387
398
trans = self.get_transport()
388
399
trans.put_bytes('name', "not an index\n")
1071
1082
index.insert_index(0, index1)
1072
1083
self.assertEqual([(index1, ('key', ), '')], list(index.iter_all_entries()))
1085
def test_clear_cache(self):
1088
class ClearCacheProxy(object):
1090
def __init__(self, index):
1093
def __getattr__(self, name):
1094
return getattr(self._index)
1096
def clear_cache(self):
1097
log.append(self._index)
1098
return self._index.clear_cache()
1100
index = CombinedGraphIndex([])
1101
index1 = self.make_index('name', 0, nodes=[(('key', ), '', ())])
1102
index.insert_index(0, ClearCacheProxy(index1))
1103
index2 = self.make_index('name', 0, nodes=[(('key', ), '', ())])
1104
index.insert_index(1, ClearCacheProxy(index2))
1105
# CombinedGraphIndex should call 'clear_cache()' on all children
1107
self.assertEqual(sorted([index1, index2]), sorted(log))
1074
1109
def test_iter_all_entries_empty(self):
1075
1110
index = CombinedGraphIndex([])
1076
1111
self.assertEqual([], list(index.iter_all_entries()))