mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
clean: separate store from runner
This commit is contained in:
parent
0e430be0ce
commit
6d683a5fac
4 changed files with 12 additions and 21 deletions
|
|
@ -6,7 +6,6 @@ import mock
|
|||
import pytest
|
||||
|
||||
from pre_commit.commands.clean import clean
|
||||
from pre_commit.util import rmtree
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
|
|
@ -21,17 +20,16 @@ def fake_old_dir(tempdir_factory):
|
|||
yield fake_old_dir
|
||||
|
||||
|
||||
def test_clean(runner_with_mocked_store, fake_old_dir):
|
||||
def test_clean(store, fake_old_dir):
|
||||
store.require_created()
|
||||
assert os.path.exists(fake_old_dir)
|
||||
assert os.path.exists(runner_with_mocked_store.store.directory)
|
||||
clean(runner_with_mocked_store)
|
||||
assert os.path.exists(store.directory)
|
||||
clean(store)
|
||||
assert not os.path.exists(fake_old_dir)
|
||||
assert not os.path.exists(runner_with_mocked_store.store.directory)
|
||||
assert not os.path.exists(store.directory)
|
||||
|
||||
|
||||
def test_clean_empty(runner_with_mocked_store):
|
||||
"""Make sure clean succeeds when the directory doesn't exist."""
|
||||
rmtree(runner_with_mocked_store.store.directory)
|
||||
assert not os.path.exists(runner_with_mocked_store.store.directory)
|
||||
clean(runner_with_mocked_store)
|
||||
assert not os.path.exists(runner_with_mocked_store.store.directory)
|
||||
def test_clean_idempotent(store):
|
||||
assert not os.path.exists(store.directory)
|
||||
clean(store)
|
||||
assert not os.path.exists(store.directory)
|
||||
|
|
|
|||
|
|
@ -11,10 +11,8 @@ import mock
|
|||
import pytest
|
||||
import six
|
||||
|
||||
import pre_commit.constants as C
|
||||
from pre_commit import output
|
||||
from pre_commit.logging_handler import add_logging_handler
|
||||
from pre_commit.runner import Runner
|
||||
from pre_commit.store import Store
|
||||
from pre_commit.util import cmd_output
|
||||
from testing.fixtures import git_dir
|
||||
|
|
@ -151,11 +149,6 @@ def store(tempdir_factory):
|
|||
yield Store(os.path.join(tempdir_factory.get(), '.pre-commit'))
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def runner_with_mocked_store(mock_out_store_directory):
|
||||
yield Runner('/', C.CONFIG_FILE)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def log_info_mock():
|
||||
with mock.patch.object(logging.getLogger('pre_commit'), 'info') as mck:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue