aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xtest_dotfiles.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/test_dotfiles.py b/test_dotfiles.py
index ad4bba6..babe43c 100755
--- a/test_dotfiles.py
+++ b/test_dotfiles.py
@@ -254,6 +254,53 @@ class DotfilesTestCase(unittest.TestCase):
dotfiles.add([os.path.join(self.homedir, package_file)])
+ def test_single_sync(self):
+ """
+ Test syncing a single file in the repo
+
+ The following repo dir exists:
+
+ bashrc
+ netrc
+ vimrc
+
+ Syncing only vimrc should have the folowing sync result in home:
+
+ .vimrc -> Dotfiles/vimrc
+
+ """
+
+ # define the repository contents
+ repo_files = (
+ ('bashrc', False),
+ ('netrc', False),
+ ('vimrc', True))
+
+ # populate the repository
+ for dotfile, _ in repo_files:
+ touch(os.path.join(self.repository, dotfile))
+
+ dotfiles = core.Dotfiles(
+ homedir=self.homedir, repository=self.repository,
+ prefix='', ignore=[], externals={}, packages=[],
+ dry_run=False)
+
+ # sync only certain dotfiles
+ for dotfile, should_sync in repo_files:
+ if should_sync:
+ dotfiles.sync(files=['.%s' % dotfile])
+
+ # verify home directory contents
+ for dotfile, should_sync in repo_files:
+ if should_sync:
+ self.assertPathEqual(
+ os.path.join(self.repository, dotfile),
+ os.path.join(self.homedir, '.%s' % dotfile))
+ else:
+ self.assertFalse(os.path.exists(
+ os.path.join(self.homedir, dotfile)))
+
+
def suite():
suite = unittest.TestLoader().loadTestsFromTestCase(DotfilesTestCase)
return suite