/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_index.py

  • Committer: Andrew Bennetts
  • Date: 2010-03-17 11:36:48 UTC
  • mto: This revision was merged to the branch mainline in revision 5141.
  • Revision ID: andrew.bennetts@canonical.com-20100317113648-4wvic5ii5b6xx8po
Add test for CombinedGraphIndex's auto-reordering behaviour.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1349
1349
        self.assertListRaises(errors.NoSuchFile, index.iter_entries_prefix,
1350
1350
                                                 [('1',)])
1351
1351
 
 
1352
    def test_reorder_after_iter_entries(self):
 
1353
        # Four indices: [key1] in index1, [key2,key3] in index2, [] in index3,
 
1354
        # [key4] in index4.
 
1355
        index = CombinedGraphIndex([])
 
1356
        index1 = self.make_index('name1', 0, nodes=[(('key1', ), '', ())])
 
1357
        index2 = self.make_index('name2', 0,
 
1358
            nodes=[(('key2', ), '', ()), (('key3', ), '', ())])
 
1359
        index3 = self.make_index('name3', 0, nodes=[])
 
1360
        index4 = self.make_index('name4', 0, nodes=[(('key4', ), '', ())])
 
1361
        index.insert_index(0, index1, '1')
 
1362
        index.insert_index(1, index2, '2')
 
1363
        index.insert_index(2, index3, '3')
 
1364
        index.insert_index(3, index4, '4')
 
1365
        # Query a key from index4 and index2.
 
1366
        self.assertLength(2, list(index.iter_entries([('key4',), ('key2',)])))
 
1367
        # Now index2 and index4 should be moved to the front (and index1 should
 
1368
        # still be before index3).
 
1369
        self.assertEqual([index2, index4, index1, index3], index._indices)
 
1370
        self.assertEqual(['2', '4', '1', '3'], index._index_names)
 
1371
 
1352
1372
    def test_validate_reloads(self):
1353
1373
        index, reload_counter = self.make_combined_index_with_missing()
1354
1374
        index.validate()