diff options
author | Jon Bernard <jbernard@tuxion.com> | 2014-01-01 10:19:04 -0500 |
---|---|---|
committer | Jon Bernard <jbernard@tuxion.com> | 2014-01-01 10:19:04 -0500 |
commit | 7a331be07c654db4868e28b5657de46bc04c800a (patch) | |
tree | 26da6b1d57050442a55cbb8d29191f3f121a9a2c | |
parent | f2a28696fadcbe259bcd5f15bf5a044d47d5f8a5 (diff) | |
download | dotfiles-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
-rwxr-xr-x | test_dotfiles.py | 23 |
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() |