Add test for cleanup_checkout
MODIFY
repo2docker/__main__.py
repo2docker/__main__.py
@@ -306,6 +306,7 @@ def make_r2d(argv=None):
r2d.environment = args.environment
# if the source exists locally we don't want to delete it at the end
+ # FIXME: Find a better way to figure out if repo is 'local'. Push this into ContentProvider?
if os.path.exists(args.repo):
r2d.cleanup_checkout = False
else:

MODIFY
tests/test_args.py
tests/test_args.py
@@ -62,3 +62,18 @@ def test_run_required():
# Can't publish any ports while running if we don't specify a command explicitly
with pytest.raises(SystemExit):
make_r2d(['-p', '8000:8000', '.'])
+
+def test_clean():
+ """
+ Test checkout is cleaned appropriately
+ """
+
+ # Don't clean when repo isn't local and we explicitly ask it to not clean
+ assert not make_r2d(['--no-clean', 'https://github.com/blah.git']).cleanup_checkout
+ # Do clean repo when repo isn't localj
+ assert make_r2d(['https://github.com/blah.git']).cleanup_checkout
+
+ # Don't clean by default when repo exists locally
+ assert not make_r2d(['.']).cleanup_checkout
+ # Don't clean when repo exists locally and we explicitly ask it to not clean
+ assert not make_r2d(['--no-clean', '.']).cleanup_checkout
\ No newline at end of file

Add test for cleanup_checkout