2015-04-08 21:20:11 +02:00
|
|
|
import pytest
|
|
|
|
from thefuck.rules.git_not_command import match, get_new_command
|
2015-04-25 02:35:26 +02:00
|
|
|
from tests.utils import Command
|
2015-04-08 21:20:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def git_not_command():
|
|
|
|
return """git: 'brnch' is not a git command. See 'git --help'.
|
|
|
|
|
|
|
|
Did you mean this?
|
|
|
|
branch
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
2015-04-20 21:48:54 +02:00
|
|
|
@pytest.fixture
|
|
|
|
def git_not_command_one_of_this():
|
|
|
|
return """git: 'st' is not a git command. See 'git --help'.
|
|
|
|
|
|
|
|
Did you mean one of these?
|
|
|
|
status
|
|
|
|
reset
|
|
|
|
stage
|
|
|
|
stash
|
|
|
|
stats
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
2015-07-08 21:33:30 +03:00
|
|
|
@pytest.fixture
|
|
|
|
def git_not_command_closest():
|
|
|
|
return '''git: 'tags' is not a git command. See 'git --help'.
|
|
|
|
|
|
|
|
Did you mean one of these?
|
2015-08-17 13:44:15 +02:00
|
|
|
\tstage
|
|
|
|
\ttag
|
2015-07-08 21:33:30 +03:00
|
|
|
'''
|
|
|
|
|
|
|
|
|
2015-04-08 21:20:11 +02:00
|
|
|
@pytest.fixture
|
|
|
|
def git_command():
|
|
|
|
return "* master"
|
|
|
|
|
|
|
|
|
2015-04-20 21:48:54 +02:00
|
|
|
def test_match(git_not_command, git_command, git_not_command_one_of_this):
|
2015-09-07 13:00:29 +03:00
|
|
|
assert match(Command('git brnch', stderr=git_not_command))
|
|
|
|
assert match(Command('git st', stderr=git_not_command_one_of_this))
|
|
|
|
assert not match(Command('ls brnch', stderr=git_not_command))
|
|
|
|
assert not match(Command('git branch', stderr=git_command))
|
2015-04-08 21:20:11 +02:00
|
|
|
|
|
|
|
|
2015-07-08 21:33:30 +03:00
|
|
|
def test_get_new_command(git_not_command, git_not_command_one_of_this,
|
|
|
|
git_not_command_closest):
|
2016-10-06 14:51:22 -04:00
|
|
|
assert (get_new_command(Command('git brnch', stderr=git_not_command))
|
|
|
|
== ['git branch'])
|
2016-10-06 15:16:43 -04:00
|
|
|
assert (get_new_command(Command('git st', stderr=git_not_command_one_of_this))
|
|
|
|
== ['git stats', 'git stash', 'git stage'])
|
|
|
|
assert (get_new_command(Command('git tags', stderr=git_not_command_closest))
|
|
|
|
== ['git tag', 'git stage'])
|