mirror of
https://github.com/nvbn/thefuck.git
synced 2025-09-27 15:42:37 +01:00
#N/A: Fix git_add
rule
This commit is contained in:
@@ -4,36 +4,28 @@ from tests.utils import Command
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def did_not_match(target, did_you_forget=True):
|
||||
error = ("error: pathspec '{}' did not match any "
|
||||
"file(s) known to git.".format(target))
|
||||
if did_you_forget:
|
||||
error = ("{}\nDid you forget to 'git add'?'".format(error))
|
||||
return error
|
||||
def stderr(target):
|
||||
return ("error: pathspec '{}' did not match any "
|
||||
'file(s) known to git.'.format(target))
|
||||
|
||||
|
||||
@pytest.mark.parametrize('command', [
|
||||
Command(script='git submodule update unknown',
|
||||
stderr=did_not_match('unknown')),
|
||||
Command(script='git commit unknown',
|
||||
stderr=did_not_match('unknown'))]) # Older versions of Git
|
||||
def test_match(command):
|
||||
assert match(command)
|
||||
@pytest.mark.parametrize('script, target', [
|
||||
('git submodule update unknown', 'unknown'),
|
||||
('git commit unknown', 'unknown')])
|
||||
def test_match(stderr, script, target):
|
||||
assert match(Command(script=script, stderr=stderr))
|
||||
|
||||
|
||||
@pytest.mark.parametrize('command', [
|
||||
Command(script='git submodule update known', stderr=('')),
|
||||
Command(script='git commit known', stderr=('')),
|
||||
Command(script='git commit unknown', # Newer versions of Git
|
||||
stderr=did_not_match('unknown', False))])
|
||||
def test_not_match(command):
|
||||
assert not match(command)
|
||||
@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('command, new_command', [
|
||||
(Command('git submodule update unknown', stderr=did_not_match('unknown')),
|
||||
@pytest.mark.parametrize('script, target, new_command', [
|
||||
('git submodule update unknown', 'unknown',
|
||||
'git add -- unknown && git submodule update unknown'),
|
||||
(Command('git commit unknown', stderr=did_not_match('unknown')), # Old Git
|
||||
('git commit unknown', 'unknown',
|
||||
'git add -- unknown && git commit unknown')])
|
||||
def test_get_new_command(command, new_command):
|
||||
assert get_new_command(command) == new_command
|
||||
def test_get_new_command(stderr, script, target, new_command):
|
||||
assert get_new_command(Command(script=script, stderr=stderr)) == new_command
|
||||
|
Reference in New Issue
Block a user