~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_knit.py

  • Committer: Aaron Bentley
  • Date: 2008-10-21 18:49:10 UTC
  • mfrom: (3788 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3789.
  • Revision ID: aaron@aaronbentley.com-20081021184910-kvfby9230xv2mbfz
merge with bzr.dev

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
        # Test for formatting with live data
 
947
        self.assertStartsWith(str(err), "Knit ")
 
948
 
 
949
 
923
950
class TestKnitIndex(KnitTests):
924
951
 
925
952
    def test_add_versions_dictionary_compresses(self):