From c5e6a9b5e53e98fc063a970dc7069559b32e40ce Mon Sep 17 00:00:00 2001 From: Jon Bernard Date: Tue, 17 Dec 2013 19:27:58 -0500 Subject: Add unit test for removing a dotfile with a missing target If the remove operation is issued on a dotfile pointing to a target that's already been removed from the repository, then the symlink should just be removed quietly. Re: #25 --- test_dotfiles.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'test_dotfiles.py') diff --git a/test_dotfiles.py b/test_dotfiles.py index 761496e..7d2605e 100755 --- a/test_dotfiles.py +++ b/test_dotfiles.py @@ -310,5 +310,26 @@ class DotfilesTestCase(unittest.TestCase): os.path.join(self.homedir, dotfile))) + def test_missing_remove(self): + """Test removing a dotfile that's been removed from the repository.""" + + repo_file = os.path.join(self.repository, 'testdotfile') + + touch(repo_file) + + dotfiles = core.Dotfiles( + homedir=self.homedir, repository=self.repository, + prefix='', ignore=[], externals={}, packages=[], + dry_run=False) + + dotfiles.sync() + + # remove the dotfile from the repository, homedir symlink is now broken + os.remove(repo_file) + + # remove the broken symlink + dotfiles.remove(['.testdotfile']) + + if __name__ == '__main__': unittest.main() -- cgit v1.2.3