summaryrefslogtreecommitdiffstats
path: root/test_dotfiles.py
diff options
context:
space:
mode:
authorGravatar Jon Bernard <jbernard@tuxion.com> 2014-01-01 10:19:04 -0500
committerGravatar Jon Bernard <jbernard@tuxion.com> 2014-01-01 10:19:04 -0500
commit7a331be07c654db4868e28b5657de46bc04c800a (patch)
tree26da6b1d57050442a55cbb8d29191f3f121a9a2c /test_dotfiles.py
parentf2a28696fadcbe259bcd5f15bf5a044d47d5f8a5 (diff)
downloaddotfiles-7a331be07c654db4868e28b5657de46bc04c800a.tar.gz
dotfiles-7a331be07c654db4868e28b5657de46bc04c800a.tar.bz2
dotfiles-7a331be07c654db4868e28b5657de46bc04c800a.zip
Add unit test for adding a missing package
This fails because the add operation is not aware of package settings, and therefore adds a package dotfiles as it normally would - as a toplevel symlink. The problem arises when a user attempts to sync and the expected symlink layout is not as it should be. With the force option, this can lead to deleted files with no way to recover. Re #20, #27
Diffstat (limited to 'test_dotfiles.py')
-rwxr-xr-xtest_dotfiles.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/test_dotfiles.py b/test_dotfiles.py
index 678d9e4..fbdae37 100755
--- a/test_dotfiles.py
+++ b/test_dotfiles.py
@@ -335,5 +335,28 @@ class DotfilesTestCase(unittest.TestCase):
os.path.join(self.homedir, '.testdotfile')))
+ def test_add_package(self):
+ """
+ Test adding a package that isn't already in the repository
+
+ """
+
+ package_dir = os.path.join(self.homedir,
+ '.%s/%s' % ('config', 'gtk-3.0'))
+
+ os.makedirs(package_dir)
+ touch('%s/testfile' % package_dir)
+
+ dotfiles = core.Dotfiles(
+ homedir=self.homedir, repository=self.repository,
+ prefix='', ignore=[], externals={}, packages=['config'],
+ dry_run=False, quiet=True)
+
+ # This should fail, you should not be able to add dotfiles that are
+ # defined to be packages.
+ dotfiles.add(['.config'])
+ self.assertFalse(os.path.islink(os.path.join(self.homedir, '.config')))
+
+
if __name__ == '__main__':
unittest.main()