~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-10-31 03:15:38 UTC
  • mfrom: (3806.1.1 contrib)
  • Revision ID: pqm@pqm.ubuntu.com-20081031031538-0ih0zi2owevf6fwu
Add contrib/bzr_ssh_path_limiter. (Andrew Bennetts)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2007 Canonical Ltd
 
2
#
 
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.
 
7
#
 
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.
 
12
#
 
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
 
16
 
 
17
"""Tests for the 'check' CLI command."""
 
18
 
 
19
from bzrlib.tests import ChrootedTestCase
 
20
from bzrlib.tests.blackbox import ExternalBase
 
21
 
 
22
 
 
23
class TestCheck(ExternalBase):
 
24
 
 
25
    def test_check_no_tree(self):
 
26
        self.make_branch('.')
 
27
        self.run_bzr('check')
 
28
 
 
29
    def test_check_initial_tree(self):
 
30
        self.make_branch_and_tree('.')
 
31
        self.run_bzr('check')
 
32
 
 
33
    def test_check_one_commit_tree(self):
 
34
        tree = self.make_branch_and_tree('.')
 
35
        tree.commit('hallelujah')
 
36
        out, err = self.run_bzr('check')
 
37
        self.assertContainsRe(err, r"^Checking working tree at '.*'\.\n"
 
38
                                   r"Checking repository at '.*'\.\n"
 
39
                                   r"checked repository.*\n"
 
40
                                   r"     1 revisions\n"
 
41
                                   r"     0 file-ids\n"
 
42
                                   r"     0 unique file texts\n"
 
43
                                   r"     0 repeated file texts\n"
 
44
                                   r"     0 unreferenced text versions\n"
 
45
                                   r"Checking branch at '.*'\.\n"
 
46
                                   r"checked branch.*\n$")
 
47
 
 
48
    def test_check_branch(self):
 
49
        tree = self.make_branch_and_tree('.')
 
50
        tree.commit('foo')
 
51
        out, err = self.run_bzr('check --branch')
 
52
        self.assertContainsRe(err, r"^Checking branch at '.*'\.\n"
 
53
                                   r"checked branch.*\n$")
 
54
 
 
55
    def test_check_repository(self):
 
56
        tree = self.make_branch_and_tree('.')
 
57
        tree.commit('foo')
 
58
        out, err = self.run_bzr('check --repo')
 
59
        self.assertContainsRe(err, r"^Checking repository at '.*'\.\n"
 
60
                                   r"checked repository.*\n"
 
61
                                   r"     1 revisions\n"
 
62
                                   r"     0 file-ids\n"
 
63
                                   r"     0 unique file texts\n"
 
64
                                   r"     0 repeated file texts\n"
 
65
                                   r"     0 unreferenced text versions$")
 
66
 
 
67
    def test_check_tree(self):
 
68
        tree = self.make_branch_and_tree('.')
 
69
        tree.commit('foo')
 
70
        out, err = self.run_bzr('check --tree')
 
71
        self.assertContainsRe(err, r"^Checking working tree at '.*'\.\n$")
 
72
 
 
73
    def test_partial_check(self):
 
74
        tree = self.make_branch_and_tree('.')
 
75
        tree.commit('foo')
 
76
        out, err = self.run_bzr('check --tree --branch')
 
77
        self.assertContainsRe(err, r"^Checking working tree at '.*'\.\n"
 
78
                                   r"Checking branch at '.*'\.\n"
 
79
                                   r"checked branch.*\n$")
 
80
 
 
81
    def test_check_missing_tree(self):
 
82
        branch = self.make_branch('.')
 
83
        out, err = self.run_bzr('check --tree')
 
84
        self.assertEqual(err, "No working tree found at specified location.\n")
 
85
 
 
86
    def test_check_missing_partial(self):
 
87
        branch = self.make_branch('.')
 
88
        out, err = self.run_bzr('check --tree --branch')
 
89
        self.assertContainsRe(err,
 
90
            r"^No working tree found at specified location\.\n"
 
91
            r"Checking branch at '.*'\.\n"
 
92
            r"checked branch.*\n$")
 
93
 
 
94
    def test_check_missing_branch_in_shared_repo(self):
 
95
        self.make_repository('shared', shared=True)
 
96
        out, err = self.run_bzr('check --branch shared')
 
97
        self.assertEqual(err, "No branch found at specified location.\n")
 
98
 
 
99
 
 
100
class ChrootedCheckTests(ChrootedTestCase):
 
101
 
 
102
    def test_check_missing_branch(self):
 
103
        out, err = self.run_bzr(
 
104
            'check --branch %s' % self.get_readonly_url(''))
 
105
        self.assertEqual(err, "No branch found at specified location.\n")
 
106
 
 
107
    def test_check_missing_repository(self):
 
108
        out, err = self.run_bzr('check --repo %s' % self.get_readonly_url(''))
 
109
        self.assertEqual(err, "No repository found at specified location.\n")
 
110
 
 
111
    def test_check_missing_everything(self):
 
112
        out, err = self.run_bzr('check %s' % self.get_readonly_url(''))
 
113
        self.assertEqual(err, "No working tree found at specified location.\n"
 
114
                              "No branch found at specified location.\n"
 
115
                              "No repository found at specified location.\n")