383
383
size = trans.put_file('index', stream)
384
384
return GraphIndex(trans, 'index', size)
386
def test_clear_cache(self):
387
index = self.make_index()
388
# For now, we just want to make sure the api is available. As this is
389
# old code, we don't really worry if it *does* anything.
386
392
def test_open_bad_index_no_error(self):
387
393
trans = self.get_transport()
388
394
trans.put_bytes('name', "not an index\n")
1071
1077
index.insert_index(0, index1)
1072
1078
self.assertEqual([(index1, ('key', ), '')], list(index.iter_all_entries()))
1080
def test_clear_cache(self):
1083
class ClearCacheProxy(object):
1085
def __init__(self, index):
1088
def __getattr__(self, name):
1089
return getattr(self._index)
1091
def clear_cache(self):
1092
log.append(self._index)
1093
return self._index.clear_cache()
1095
index = CombinedGraphIndex([])
1096
index1 = self.make_index('name', 0, nodes=[(('key', ), '', ())])
1097
index.insert_index(0, ClearCacheProxy(index1))
1098
index2 = self.make_index('name', 0, nodes=[(('key', ), '', ())])
1099
index.insert_index(1, ClearCacheProxy(index2))
1100
# CombinedGraphIndex should call 'clear_cache()' on all children
1102
self.assertEqual(sorted([index1, index2]), sorted(log))
1074
1104
def test_iter_all_entries_empty(self):
1075
1105
index = CombinedGraphIndex([])
1076
1106
self.assertEqual([], list(index.iter_all_entries()))