From 33f63740fdc9e738a9638d94f0f646c762472b89 Mon Sep 17 00:00:00 2001 From: Jon Bernard Date: Thu, 27 Jun 2013 10:43:12 -0400 Subject: Add a unit test for non-existent package directories If a package is defined in .dotfilesrc and the package directory doesn't exist in the repository when you attempt to add it, an IOError exception is thrown. This test captures the failing scenario. In reference to #17. --- test_dotfiles.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test_dotfiles.py b/test_dotfiles.py index cce8009..ad4bba6 100755 --- a/test_dotfiles.py +++ b/test_dotfiles.py @@ -232,6 +232,27 @@ class DotfilesTestCase(unittest.TestCase): dotfiles.move(self.repository) check_all(files, symlinks) + def test_missing_package(self): + """ + Test a non-existent package. + """ + + package_file = '.package/bar' + + # Create Dotfiles object + dotfiles = core.Dotfiles( + homedir=self.homedir, repository=self.repository, + prefix='', ignore=[], externals={}, packages=['package'], + dry_run=False) + + path = os.path.join(self.homedir, package_file) + dirname = os.path.dirname(path) + if not os.path.exists(dirname): + os.makedirs(dirname) + touch(path) + + dotfiles.add([os.path.join(self.homedir, package_file)]) + def suite(): suite = unittest.TestLoader().loadTestsFromTestCase(DotfilesTestCase) -- cgit v1.2.3