mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
tests/repo: move .destroy to unit test
This commit is contained in:
@@ -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)
|
||||
@@ -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"))
|
||||
|
||||
Reference in New Issue
Block a user