From 7a331be07c654db4868e28b5657de46bc04c800a Mon Sep 17 00:00:00 2001 From: Jon Bernard Date: Wed, 1 Jan 2014 10:19:04 -0500 Subject: 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 --- test_dotfiles.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'test_dotfiles.py') 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() -- cgit v1.2.3