~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-06-29 00:31:00 UTC
  • mto: This revision was merged to the branch mainline in revision 2614.
  • Revision ID: john@arbash-meinel.com-20070629003100-xthewxf3hpdes9ix
Add a test that KnitCorrupt is raised when parent strings are invalid.
And fix *both* implementations so that they do the right thing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
698
698
        self.assertRaises(RevisionNotPresent, check, ["c"])
699
699
        self.assertRaises(RevisionNotPresent, check, ["a", "b", "c"])
700
700
 
 
701
    def test_impossible_parent(self):
 
702
        """Test we get KnitCorrupt if the parent couldn't possibly exist."""
 
703
        transport = MockTransport([
 
704
            _KnitIndex.HEADER,
 
705
            "a option 0 1 :",
 
706
            "b option 0 1 4 :"  # We don't have a 4th record
 
707
            ])
 
708
        self.assertRaises(errors.KnitCorrupt,
 
709
                          self.get_knit_index, transport, 'filename', 'r')
 
710
 
 
711
    def test_corrupted_parent(self):
 
712
        transport = MockTransport([
 
713
            _KnitIndex.HEADER,
 
714
            "a option 0 1 :",
 
715
            "b option 0 1 :",
 
716
            "c option 0 1 1v :", # Can't have a parent of '1v'
 
717
            ])
 
718
        self.assertRaises(errors.KnitCorrupt,
 
719
                          self.get_knit_index, transport, 'filename', 'r')
 
720
 
 
721
    def test_corrupted_parent_in_list(self):
 
722
        transport = MockTransport([
 
723
            _KnitIndex.HEADER,
 
724
            "a option 0 1 :",
 
725
            "b option 0 1 :",
 
726
            "c option 0 1 2 v :", # Can't have a parent of 'v'
 
727
            ])
 
728
        self.assertRaises(errors.KnitCorrupt,
 
729
                          self.get_knit_index, transport, 'filename', 'r')
 
730
 
701
731
 
702
732
class LowLevelKnitIndexTests_c(LowLevelKnitIndexTests):
703
733