summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Jon Bernard <jbernard@tuxion.com> 2013-06-27 10:43:12 -0400
committerGravatar Jon Bernard <jbernard@tuxion.com> 2013-11-07 09:38:44 -0500
commit33f63740fdc9e738a9638d94f0f646c762472b89 (patch)
tree7714d71a29d1883dc85ad4e6570586b76b71680d
parent52551696de34a28dd5de1799aaa2ec50c50aceb4 (diff)
downloaddotfiles-33f63740fdc9e738a9638d94f0f646c762472b89.tar.gz
dotfiles-33f63740fdc9e738a9638d94f0f646c762472b89.tar.bz2
dotfiles-33f63740fdc9e738a9638d94f0f646c762472b89.zip
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.
-rwxr-xr-xtest_dotfiles.py21
1 files changed, 21 insertions, 0 deletions
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)