~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_knit.py

  • Committer: John Arbash Meinel
  • Date: 2007-07-05 19:39:28 UTC
  • mto: This revision was merged to the branch mainline in revision 2614.
  • Revision ID: john@arbash-meinel.com-20070705193928-xtm8nh4ucc8qosdn
Add direct tests of how we handle incomplete/'broken' lines

Show diffs side-by-side

added added

removed removed

Lines of Context:
795
795
            else:
796
796
                raise
797
797
 
 
798
    def test_short_line(self):
 
799
        transport = MockTransport([
 
800
            _KnitIndex.HEADER,
 
801
            "a option 0 10  :",
 
802
            "b option 10 10 0", # This line isn't terminated, ignored
 
803
            ])
 
804
        index = self.get_knit_index(transport, "filename", "r")
 
805
        self.assertEqual(['a'], index.get_versions())
 
806
 
 
807
    def test_skip_incomplete_record(self):
 
808
        # A line with bogus data should just be skipped
 
809
        transport = MockTransport([
 
810
            _KnitIndex.HEADER,
 
811
            "a option 0 10  :",
 
812
            "b option 10 10 0", # This line isn't terminated, ignored
 
813
            "c option 20 10 0 :", # Properly terminated, and starts with '\n'
 
814
            ])
 
815
        index = self.get_knit_index(transport, "filename", "r")
 
816
        self.assertEqual(['a', 'c'], index.get_versions())
 
817
 
 
818
    def test_trailing_characters(self):
 
819
        # A line with bogus data should just be skipped
 
820
        transport = MockTransport([
 
821
            _KnitIndex.HEADER,
 
822
            "a option 0 10  :",
 
823
            "b option 10 10 0 :a", # This line has extra trailing characters
 
824
            "c option 20 10 0 :", # Properly terminated, and starts with '\n'
 
825
            ])
 
826
        index = self.get_knit_index(transport, "filename", "r")
 
827
        self.assertEqual(['a', 'c'], index.get_versions())
 
828
 
798
829
 
799
830
class LowLevelKnitIndexTests_c(LowLevelKnitIndexTests):
800
831