1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-09-27 15:42:37 +01:00

#N/A: Match git_add only if pathspec exists

This commit is contained in:
Vladimir Iakovlev
2016-08-23 13:03:49 +03:00
parent cae76eb55f
commit 4fe64e3dfa
2 changed files with 27 additions and 9 deletions

View File

@@ -3,6 +3,12 @@ from thefuck.rules.git_add import match, get_new_command
from tests.utils import Command
@pytest.fixture(autouse=True)
def path_exists(mocker):
return mocker.patch('thefuck.rules.git_add.Path.exists',
return_value=True)
@pytest.fixture
def stderr(target):
return ("error: pathspec '{}' did not match any "
@@ -16,10 +22,13 @@ def test_match(stderr, script, target):
assert match(Command(script=script, stderr=stderr))
@pytest.mark.parametrize('script', [
'git submodule update known', 'git commit known'])
def test_not_match(script):
assert not match(Command(script=script, stderr=''))
@pytest.mark.parametrize('script, target, exists', [
('git submodule update known', '', True),
('git commit known', '', True),
('git submodule update known', stderr, False)])
def test_not_match(path_exists, stderr, script, target, exists):
path_exists.return_value = exists
assert not match(Command(script=script, stderr=stderr))
@pytest.mark.parametrize('script, target, new_command', [