~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

Merge with extras

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Tests for the 'check' CLI command."""
18
18
 
 
19
from bzrlib.tests import ChrootedTestCase
19
20
from bzrlib.tests.blackbox import ExternalBase
20
21
 
21
22
 
43
44
                                   r"     0 unreferenced text versions\n"
44
45
                                   r"Checking branch at '.*'\.\n"
45
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")