~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_dump_btree.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-02-09 17:10:05 UTC
  • mfrom: (5651.2.2 dump-btree-traceback)
  • Revision ID: pqm@pqm.ubuntu.com-20110209171005-2kb2a57fn3djkfv6
(vila) Fix a traceback attempting to "bzr dump-btree --raw" a btree file
 that's well formed, but has no data rows. (Eric Siegerman)

Show diffs side-by-side

added added

removed removed

Lines of Context:
91
91
        finally:
92
92
            out_f.close()
93
93
        out, err = self.run_bzr('dump-btree test.btree')
 
94
 
 
95
    def create_sample_empty_btree_index(self):
 
96
        builder = btree_index.BTreeBuilder(
 
97
            reference_lists=1, key_elements=2)
 
98
        out_f = builder.finish()
 
99
        try:
 
100
            self.build_tree_contents([('test.btree', out_f.read())])
 
101
        finally:
 
102
            out_f.close()
 
103
 
 
104
    def test_dump_empty_btree_smoke(self):
 
105
        self.create_sample_empty_btree_index()
 
106
        out, err = self.run_bzr('dump-btree test.btree')
 
107
        self.assertEqualDiff("", out)
 
108
 
 
109
    def test_dump_empty_btree_http_smoke(self):
 
110
        self.transport_readonly_server = http_server.HttpServer
 
111
        self.create_sample_empty_btree_index()
 
112
        url = self.get_readonly_url('test.btree')
 
113
        out, err = self.run_bzr(['dump-btree', url])
 
114
        self.assertEqualDiff("", out)
 
115
 
 
116
    def test_dump_empty_btree_raw_smoke(self):
 
117
        self.create_sample_empty_btree_index()
 
118
        out, err = self.run_bzr('dump-btree test.btree --raw')
 
119
        self.assertEqualDiff(
 
120
            'Root node:\n'
 
121
            'B+Tree Graph Index 2\n'
 
122
            'node_ref_lists=1\n'
 
123
            'key_elements=2\n'
 
124
            'len=0\n'
 
125
            'row_lengths=\n'
 
126
            '\n'
 
127
            'Page 0\n'
 
128
            '(empty)\n',
 
129
            out)
 
130