diff --git a/tests/func/test_destroy.py b/tests/func/test_destroy.py deleted file mode 100644 index 3535c9d7a..000000000 --- a/tests/func/test_destroy.py +++ /dev/null @@ -1,28 +0,0 @@ -import os - -from dvc.system import System - - -def test_destroy(repo_dir, dvc_repo): - # NOTE: using symlink to ensure that data was unprotected after `destroy` - dvc_repo.config.set("cache", "type", "symlink") - - foo_stage, = dvc_repo.add(repo_dir.FOO) - data_dir_stage, = dvc_repo.add(repo_dir.DATA_DIR) - - dvc_repo.destroy() - - assert not os.path.exists(dvc_repo.dvc_dir) - assert not os.path.exists(foo_stage.path) - assert not os.path.exists(data_dir_stage.path) - - assert os.path.isfile(repo_dir.FOO) - assert os.path.isdir(repo_dir.DATA_DIR) - assert os.path.isfile(repo_dir.DATA) - assert os.path.isdir(repo_dir.DATA_SUB_DIR) - assert os.path.isfile(repo_dir.DATA_SUB) - - assert not System.is_symlink(repo_dir.FOO) - assert not System.is_symlink(repo_dir.DATA_DIR) - assert not System.is_symlink(repo_dir.DATA) - assert not System.is_symlink(repo_dir.DATA_SUB) diff --git a/tests/unit/test_repo.py b/tests/unit/test_repo.py index f21c5a0f0..6f286e94d 100644 --- a/tests/unit/test_repo.py +++ b/tests/unit/test_repo.py @@ -1,6 +1,34 @@ +from dvc.system import System from dvc.utils.compat import fspath def test_is_dvc_internal(tmp_dir, dvc): assert dvc.is_dvc_internal(fspath(tmp_dir / ".dvc" / "file")) assert not dvc.is_dvc_internal("file") + + +def test_destroy(tmp_dir, dvc): + dvc.config.set("cache", "type", "symlink") + + tmp_dir.dvc_gen('file', 'text') + tmp_dir.dvc_gen({'dir': {'file': 'lorem', 'subdir/file': 'ipsum'}}) + + dvc.destroy() + + # Remove all the files related to DVC + assert not (tmp_dir / ".dvc").exists() + assert not (tmp_dir / "file.dvc").exists() + assert not (tmp_dir / "dir.dvc").exists() + + # Leave the rest of the files + assert (tmp_dir / "file").is_file() + assert (tmp_dir / "dir").is_dir() + assert (tmp_dir / "dir" / "file").is_file() + assert (tmp_dir / "dir" / "subdir" / "file").is_file() + + # Make sure that data was unprotected after `destroy` + assert not System.is_symlink(fspath(tmp_dir / "foo")) + assert not System.is_symlink(fspath(tmp_dir / "file")) + assert not System.is_symlink(fspath(tmp_dir / "dir")) + assert not System.is_symlink(fspath(tmp_dir / "dir" / "file")) + assert not System.is_symlink(fspath(tmp_dir / "dir" / "subdir" / "file"))