aboutsummaryrefslogtreecommitdiffstats
path: root/test_dotfiles.py
diff options
context:
space:
mode:
authorGravatar Jon Bernard <jbernard@tuxion.com> 2011-10-05 19:19:37 -0400
committerGravatar Jon Bernard <jbernard@tuxion.com> 2011-10-05 19:19:37 -0400
commit392ae7974f7aed0c8ff6510d187caaa41b11d2ff (patch)
tree8efa370cd55884e6bee8b9b1c2902959e021cb25 /test_dotfiles.py
parentcd0d973446dbb5409323d077371a6ebc98836f80 (diff)
parentbf73e1f7d50506ff6ac58e5f70e1ac9f0412e1d3 (diff)
downloaddotfiles-392ae7974f7aed0c8ff6510d187caaa41b11d2ff.tar.gz
dotfiles-392ae7974f7aed0c8ff6510d187caaa41b11d2ff.tar.bz2
dotfiles-392ae7974f7aed0c8ff6510d187caaa41b11d2ff.zip
Merge branch 'release/0.4.2'v0.4.2
Diffstat (limited to 'test_dotfiles.py')
-rwxr-xr-xtest_dotfiles.py39
1 files changed, 37 insertions, 2 deletions
diff --git a/test_dotfiles.py b/test_dotfiles.py
index 360d7db..bb54578 100755
--- a/test_dotfiles.py
+++ b/test_dotfiles.py
@@ -21,7 +21,7 @@ class DotfilesTestCase(unittest.TestCase):
self.home = tempfile.mkdtemp()
- # create a repository for the tests to use
+ # Create a repository for the tests to use.
self.repo = os.path.join(self.home, 'Dotfiles')
os.mkdir(self.repo)
@@ -62,7 +62,7 @@ class DotfilesTestCase(unittest.TestCase):
dotfiles.sync()
- # make sure sync() did the right thing
+ # Make sure sync() did the right thing.
self.assertEqual(
os.path.realpath(os.path.join(self.home, '.bashrc')),
os.path.join(self.repo, 'bashrc'))
@@ -76,6 +76,41 @@ class DotfilesTestCase(unittest.TestCase):
os.path.realpath(os.path.join(self.home, '.bashrc')),
os.path.join(target, 'bashrc'))
+ def test_sync_unmanaged_directory_symlink(self):
+ """Test a forced sync on a directory symlink.
+
+ A bug was reported where a user wanted to replace a dotfile repository
+ with an other one. They had a .vim directory in their home directory
+ which was obviously also a symbolic link. This caused:
+
+ OSError: Cannot call rmtree on a symbolic link
+ """
+
+ # Create a dotfile symlink to some directory
+ os.mkdir(os.path.join(self.home, 'vim'))
+ os.symlink(os.path.join(self.home, 'vim'),
+ os.path.join(self.home, '.vim'))
+
+ # Create a vim directory in the repository. This will cause the above
+ # symlink to be overwritten on sync.
+ os.mkdir(os.path.join(self.repo, 'vim'))
+
+ # Make sure the symlink points to the correct location.
+ self.assertEqual(
+ os.path.realpath(os.path.join(self.home, '.vim')),
+ os.path.join(self.home, 'vim'))
+
+ dotfiles = core.Dotfiles(
+ home=self.home, repo=self.repo, prefix='',
+ ignore=[], externals={})
+
+ dotfiles.sync(force=True)
+
+ # The symlink should now point to the directory in the repository.
+ self.assertEqual(
+ os.path.realpath(os.path.join(self.home, '.vim')),
+ os.path.join(self.repo, 'vim'))
+
def suite():
suite = unittest.TestLoader().loadTestsFromTestCase(DotfilesTestCase)