1
# Copyright (C) 2007 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
17
"""Test that all Tree's implement get_symlink_target"""
26
from bzrlib.tests.tree_implementations import TestCaseWithTree
29
class TestGetSymlinkTarget(TestCaseWithTree):
31
def get_tree_with_symlinks(self):
32
if not osutils.has_symlinks():
33
raise tests.TestSkipped('platform does not support symlinks.')
35
tree = self.make_branch_and_tree('tree')
36
os.symlink('foo', 'tree/link')
37
os.symlink('../bar', 'tree/rel_link')
38
os.symlink('/baz/bing', 'tree/abs_link')
40
tree.add(['link', 'rel_link', 'abs_link'],
41
['link-id', 'rel-link-id', 'abs-link-id'])
42
return self._convert_tree(tree)
44
def test_get_symlink_target(self):
45
tree = self.get_tree_with_symlinks()
47
self.addCleanup(tree.unlock)
48
self.assertEqual('foo', tree.get_symlink_target('link-id'))
49
self.assertEqual('../bar', tree.get_symlink_target('rel-link-id'))
50
self.assertEqual('/baz/bing', tree.get_symlink_target('abs-link-id'))