~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_knit.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-12-12 00:36:35 UTC
  • mfrom: (2171.1.1 knit-ignore-empty-files)
  • Revision ID: pqm@pqm.ubuntu.com-20061212003635-60d7dad38f39d19b
(John Arbash Meinel) Knit index objects should ignore empty index files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import difflib
21
21
 
22
22
 
 
23
from bzrlib import errors
23
24
from bzrlib.errors import KnitError, RevisionAlreadyPresent, NoSuchFile
24
25
from bzrlib.knit import (
25
26
    KnitContent,
85
86
        self.assertEqual(it.next(), (1, 2, 2, [("", "a"), ("", "c")]))
86
87
        self.assertRaises(StopIteration, it.next)
87
88
 
 
89
 
88
90
class KnitTests(TestCaseWithTransport):
89
91
    """Class containing knit test helper routines."""
90
92
 
746
748
        # And it shouldn't be modified
747
749
        self.assertEqual(['a-1'], idx._history)
748
750
        self.assertEqual({'a-1':('a-1', ['fulltext'], 0, 0, [], 0)}, idx._cache)
 
751
 
 
752
    def test_knit_index_ignores_empty_files(self):
 
753
        # There was a race condition in older bzr, where a ^C at the right time
 
754
        # could leave an empty .kndx file, which bzr would later claim was a
 
755
        # corrupted file since the header was not present. In reality, the file
 
756
        # just wasn't created, so it should be ignored.
 
757
        t = get_transport('.')
 
758
        t.put_bytes('test.kndx', '')
 
759
 
 
760
        knit = self.make_test_knit()
 
761
 
 
762
    def test_knit_index_checks_header(self):
 
763
        t = get_transport('.')
 
764
        t.put_bytes('test.kndx', '# not really a knit header\n\n')
 
765
 
 
766
        self.assertRaises(errors.KnitHeaderError, self.make_test_knit)