~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_pack_repository.py

  • Committer: John Arbash Meinel
  • Date: 2009-05-11 18:59:15 UTC
  • mto: This revision was merged to the branch mainline in revision 4392.
  • Revision ID: john@arbash-meinel.com-20090511185915-syglc7tz3vsprwpu
Some cleanup passes.

move test_resume_chk_bytes from per_repository_referece to test_pack_repository,
as it is a bit more implementation specific.
Make sure we don't allow get_stream_for_missing_keys() if we have a pending stream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
663
663
        md5 = osutils.md5(upload_transport.get_bytes(expected_pack_name))
664
664
        self.assertEqual(wg_tokens[0], md5.hexdigest())
665
665
 
 
666
    def test_resume_chk_bytes(self):
 
667
        self.vfs_transport_factory = memory.MemoryServer
 
668
        repo = self.make_repository('repo', format=self.get_format())
 
669
        if repo.chk_bytes is None:
 
670
            raise TestNotApplicable('no chk_bytes for this repository')
 
671
            expected_names.append(wg_tokens[0] + '.cix')
 
672
        token = repo.lock_write()
 
673
        self.addCleanup(repo.unlock)
 
674
        repo.start_write_group()
 
675
        text = 'a bit of text\n'
 
676
        key = ('sha1:' + osutils.sha_string(text),)
 
677
        repo.chk_bytes.add_lines(key, (), [text])
 
678
        wg_tokens = repo.suspend_write_group()
 
679
        same_repo = repo.bzrdir.open_repository()
 
680
        same_repo.lock_write()
 
681
        self.addCleanup(same_repo.unlock)
 
682
        same_repo.resume_write_group(wg_tokens)
 
683
        self.assertEqual([key], list(same_repo.chk_bytes.keys()))
 
684
        self.assertEqual(
 
685
            text, same_repo.chk_bytes.get_record_stream([key],
 
686
                'unordered', True).next().get_bytes_as('fulltext'))
 
687
        same_repo.abort_write_group()
 
688
        self.assertEqual([], list(same_repo.chk_bytes.keys()))
 
689
 
666
690
    def test_resume_write_group_then_abort(self):
667
691
        # Create a repo, start a write group, insert some data, suspend.
668
692
        self.vfs_transport_factory = memory.MemoryServer
959
983
         dict(format_name='development6-rich-root',
960
984
              format_string='Bazaar development format - group compression '
961
985
                  'and chk inventory (needs bzr.dev from 1.14)\n',
962
 
              format_supports_external_lookups=False,
 
986
              format_supports_external_lookups=True,
963
987
              index_class=BTreeGraphIndex),
964
988
         ]
965
989
    # name of the scenario is the format name