/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_knit.py

  • Committer: Robert Collins
  • Date: 2008-10-21 03:36:14 UTC
  • mto: This revision was merged to the branch mainline in revision 3788.
  • Revision ID: robertc@robertcollins.net-20081021033614-e29ktibkuh7e5zps
Embed the failed text in sha1 knit errors.

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
    TestCase,
55
55
    TestCaseWithMemoryTransport,
56
56
    TestCaseWithTransport,
 
57
    TestNotApplicable,
57
58
    )
58
59
from bzrlib.transport import get_transport
59
60
from bzrlib.transport.memory import MemoryTransport
920
921
        return make_file_factory(annotate, mapper)(self.get_transport())
921
922
 
922
923
 
 
924
class TestBadShaError(KnitTests):
 
925
    """Tests for handling of sha errors."""
 
926
 
 
927
    def test_exception_has_text(self):
 
928
        # having the failed text included in the error allows for recovery.
 
929
        source = self.make_test_knit()
 
930
        target = self.make_test_knit(name="target")
 
931
        if not source._max_delta_chain:
 
932
            raise TestNotApplicable(
 
933
                "cannot get delta-caused sha failures without deltas.")
 
934
        # create a basis
 
935
        basis = ('basis',)
 
936
        broken = ('broken',)
 
937
        source.add_lines(basis, (), ['foo\n'])
 
938
        source.add_lines(broken, (basis,), ['foo\n', 'bar\n'])
 
939
        # Seed target with a bad basis text
 
940
        target.add_lines(basis, (), ['gam\n'])
 
941
        target.insert_record_stream(
 
942
            source.get_record_stream([broken], 'unordered', False))
 
943
        err = self.assertRaises(errors.KnitCorrupt,
 
944
            target.get_record_stream([broken], 'unordered', True).next)
 
945
        self.assertEqual(['gam\n', 'bar\n'], err.content)
 
946
 
 
947
 
923
948
class TestKnitIndex(KnitTests):
924
949
 
925
950
    def test_add_versions_dictionary_compresses(self):