aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Remco Wendt <remco@maykinmedia.nl> 2011-10-23 23:53:09 +0200
committerGravatar Remco Wendt <remco@maykinmedia.nl> 2011-10-23 23:53:09 +0200
commit1c9d0a6641863de75e6c218882dfcdce051c1471 (patch)
treed01ab13b1131fdf01616eee173b2eb3871fc5c60
parentfe9996bf08c93d9b22fbed3b70c2fe19e670a8fd (diff)
downloaddotfiles-1c9d0a6641863de75e6c218882dfcdce051c1471.tar.gz
dotfiles-1c9d0a6641863de75e6c218882dfcdce051c1471.tar.bz2
dotfiles-1c9d0a6641863de75e6c218882dfcdce051c1471.zip
Added unit test for glob pattern, which fail horribly yay!
-rwxr-xr-xtest_dotfiles.py60
1 files changed, 60 insertions, 0 deletions
diff --git a/test_dotfiles.py b/test_dotfiles.py
index f82f3ae..d12b5b0 100755
--- a/test_dotfiles.py
+++ b/test_dotfiles.py
@@ -112,6 +112,66 @@ class DotfilesTestCase(unittest.TestCase):
os.path.realpath(os.path.join(self.home, '.vim')),
os.path.realpath(os.path.join(self.repo, 'vim')))
+ def test_glob_ignore_pattern(self):
+ """ Test that the use of glob pattern matching works in the ignores list.
+
+ The following repo dir exists:
+
+ myscript.py
+ myscript.pyc
+ myscript.pyo
+ bashrc
+ bashrc.swp
+ vimrc
+ vimrc.swp
+ install.sh
+
+ Using the glob pattern dotfiles should have the following sync result in home:
+
+ .myscript.py -> Dotfiles/myscript.py
+ .bashrc -> Dotfiles/bashrc
+ .vimrc -> Dotfiles/vimrc
+
+ """
+ ignore = ['*.swp', '.py?', 'install.sh']
+
+ all_repo_files = (
+ ('myscript.py', '.myscript.py'),
+ ('myscript.pyc', None),
+ ('myscript.pyo', None),
+ ('bashrc', '.bashrc'),
+ ('bashrc.swp', None),
+ ('vimrc', '.vimrc'),
+ ('vimrc.swp', None),
+ ('install.sh', None)
+ )
+
+ all_dotfiles = [f for f in all_repo_files if f[1] is not None]
+
+ for original, symlink in all_repo_files:
+ touch(os.path.join(self.repo, original))
+
+ dotfiles = core.Dotfiles(
+ home=self.home, repo=self.repo, prefix='',
+ ignore=ignore, externals={})
+
+ dotfiles.sync()
+
+ # Now check that the files that should have a symlink
+ # point to the correct file and are the only files that
+ # exist in the home dir.
+ self.assertEqual(
+ sorted(os.listdir(self.home)),
+ sorted([f[1] for f in all_dotfiles]))
+
+ for original, symlink in all_dotfiles:
+ original_path = os.path.join(self.repo, original)
+ symlink_path = os.path.join(self.home, symlink)
+
+ self.assertEqual(
+ os.path.realpath(original_path),
+ os.path.realpath(symlink_path))
+
def suite():
suite = unittest.TestLoader().loadTestsFromTestCase(DotfilesTestCase)