1
# Copyright (C) 2008-2011, 2016 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
"""Tests of the 'bzr alias' command."""
24
from bzrlib.tests import (
29
class TestAlias(tests.TestCaseWithTransport):
31
def test_list_alias_with_none(self):
32
"""Calling alias with no parameters lists existing aliases."""
33
out, err = self.run_bzr('alias')
34
self.assertEqual('', out)
36
def test_list_unknown_alias(self):
37
out, err = self.run_bzr('alias commit')
38
self.assertEqual('bzr alias: commit: not found\n', out)
40
def test_add_alias_outputs_nothing(self):
41
out, err = self.run_bzr('alias commit="commit --strict"')
42
self.assertEqual('', out)
44
def test_add_alias_visible(self):
45
"""Adding an alias makes it ..."""
46
self.run_bzr('alias commit="commit --strict"')
47
out, err = self.run_bzr('alias commit')
48
self.assertEqual('bzr alias commit="commit --strict"\n', out)
50
def test_unicode_alias(self):
51
"""Unicode aliases should work (Bug #529930)"""
52
# XXX: strictly speaking, lack of unicode filenames doesn't imply that
53
# unicode command lines aren't available.
54
self.requireFeature(features.UnicodeFilenameFeature)
55
file_name = u'foo\xb6'
57
tree = self.make_branch_and_tree('.')
58
self.build_tree([file_name])
62
config.GlobalConfig.from_string(
63
u'[ALIASES]\nust=st %s\n' % (file_name,), save=True)
65
out, err = self.run_bzr('ust')
66
self.assertEqual(err, '')
67
self.assertEqual(out, '')
69
def test_alias_listing_alphabetical(self):
70
self.run_bzr('alias commit="commit --strict"')
71
self.run_bzr('alias ll="log --short"')
72
self.run_bzr('alias add="add -q"')
74
out, err = self.run_bzr('alias')
76
'bzr alias add="add -q"\n'
77
'bzr alias commit="commit --strict"\n'
78
'bzr alias ll="log --short"\n',
81
def test_remove_unknown_alias(self):
82
out, err = self.run_bzr('alias --remove fooix', retcode=3)
83
self.assertEqual('bzr: ERROR: The alias "fooix" does not exist.\n',
86
def test_remove_known_alias(self):
87
self.run_bzr('alias commit="commit --strict"')
88
out, err = self.run_bzr('alias commit')
89
self.assertEqual('bzr alias commit="commit --strict"\n', out)
90
# No output when removing an existing alias.
91
out, err = self.run_bzr('alias --remove commit')
92
self.assertEqual('', out)
94
out, err = self.run_bzr('alias commit')
95
self.assertEqual("bzr alias: commit: not found\n", out)