1
# Copyright (C) 2008 Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
"""Tests of the 'bzr dump-btree' command."""
24
from bzrlib.tests import (
29
class TestDumpBtree(tests.TestCaseWithTransport):
31
def create_sample_btree_index(self):
32
builder = btree_index.BTreeBuilder(
33
reference_lists=1, key_elements=2)
34
builder.add_node(('test', 'key1'), 'value', ((('ref', 'entry'),),))
35
builder.add_node(('test', 'key2'), 'value2', ((('ref', 'entry2'),),))
36
builder.add_node(('test2', 'key3'), 'value3', ((('ref', 'entry3'),),))
37
out_f = builder.finish()
39
self.build_tree_contents([('test.btree', out_f.read())])
43
def test_dump_btree_smoke(self):
44
self.create_sample_btree_index()
45
out, err = self.run_bzr('dump-btree test.btree')
47
"(('test', 'key1'), 'value', ((('ref', 'entry'),),))\n"
48
"(('test', 'key2'), 'value2', ((('ref', 'entry2'),),))\n"
49
"(('test2', 'key3'), 'value3', ((('ref', 'entry3'),),))\n",
52
def test_dump_btree_http_smoke(self):
53
self.transport_readonly_server = http_server.HttpServer
54
self.create_sample_btree_index()
55
url = self.get_readonly_url('test.btree')
56
out, err = self.run_bzr(['dump-btree', url])
58
"(('test', 'key1'), 'value', ((('ref', 'entry'),),))\n"
59
"(('test', 'key2'), 'value2', ((('ref', 'entry2'),),))\n"
60
"(('test2', 'key3'), 'value3', ((('ref', 'entry3'),),))\n",
63
def test_dump_btree_raw_smoke(self):
64
self.create_sample_btree_index()
65
out, err = self.run_bzr('dump-btree test.btree --raw')
68
'B+Tree Graph Index 2\n'
76
'test\0key1\0ref\0entry\0value\n'
77
'test\0key2\0ref\0entry2\0value2\n'
78
'test2\0key3\0ref\0entry3\0value3\n'