~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_index.py

  • Committer: Robert Collins
  • Date: 2007-07-12 15:47:29 UTC
  • mto: (2592.5.3 pack-repository)
  • mto: This revision was merged to the branch mainline in revision 2624.
  • Revision ID: robertc@robertcollins.net-20070712154729-ln0fpixap5lkcnsj
Make validate detect node reference parsing errors.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
        contents = stream.read()
36
36
        self.assertEqual("Bazaar Graph Index 1\nnode_ref_lists=1\n\n", contents)
37
37
 
 
38
    def test_build_index_two_reference_list_empty(self):
 
39
        builder = GraphIndexBuilder(reference_lists=2)
 
40
        stream = builder.finish()
 
41
        contents = stream.read()
 
42
        self.assertEqual("Bazaar Graph Index 1\nnode_ref_lists=2\n\n", contents)
 
43
 
38
44
 
39
45
class TestGraphIndex(TestCaseWithMemoryTransport):
40
46
 
41
 
    def make_index(self):
 
47
    def make_index(self, ref_lists=0):
42
48
        builder = GraphIndexBuilder()
43
49
        stream = builder.finish()
44
50
        trans = self.get_transport()
68
74
        index = GraphIndex(trans, 'name')
69
75
        self.assertRaises(errors.BadIndexFormatSignature, index.validate)
70
76
 
 
77
    def test_validate_bad_node_refs(self):
 
78
        index = self.make_index(2)
 
79
        trans = self.get_transport()
 
80
        content = trans.get_bytes('index')
 
81
        # change the options line to end with a rather than a parseable number
 
82
        new_content = content[:-2] + 'a\n\n'
 
83
        trans.put_bytes('index', new_content)
 
84
        self.assertRaises(errors.BadIndexOptions, index.validate)
 
85
 
71
86
    def test_validate_empty(self):
72
87
        index = self.make_index()
73
88
        index.validate()