~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_index.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-10-20 05:12:09 UTC
  • mfrom: (4744.2.9 2.1-peak-mem-tweak)
  • Revision ID: pqm@pqm.ubuntu.com-20091020051209-telne1xq2bq6cp7m
(jam) In GCCHKStreamSource clear caches after we fetch from a VF

Show diffs side-by-side

added added

removed removed

Lines of Context:
173
173
            "key\x00\x00\t\x00data\n"
174
174
            "\n", contents)
175
175
 
 
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()
 
180
 
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)
385
390
 
 
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.
 
395
        index.clear_cache()
 
396
 
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()))
1073
1084
 
 
1085
    def test_clear_cache(self):
 
1086
        log = []
 
1087
 
 
1088
        class ClearCacheProxy(object):
 
1089
 
 
1090
            def __init__(self, index):
 
1091
                self._index = index
 
1092
 
 
1093
            def __getattr__(self, name):
 
1094
                return getattr(self._index)
 
1095
 
 
1096
            def clear_cache(self):
 
1097
                log.append(self._index)
 
1098
                return self._index.clear_cache()
 
1099
 
 
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
 
1106
        index.clear_cache()
 
1107
        self.assertEqual(sorted([index1, index2]), sorted(log))
 
1108
 
1074
1109
    def test_iter_all_entries_empty(self):
1075
1110
        index = CombinedGraphIndex([])
1076
1111
        self.assertEqual([], list(index.iter_all_entries()))