2015-04-23 17:00:57 +09:00
|
|
|
import pytest
|
|
|
|
from thefuck.rules.brew_unknown_command import match, get_new_command
|
|
|
|
from thefuck.rules.brew_unknown_command import brew_commands
|
2015-04-25 02:35:26 +02:00
|
|
|
from tests.utils import Command
|
2015-04-23 17:00:57 +09:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def brew_unknown_cmd():
|
|
|
|
return '''Error: Unknown command: inst'''
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def brew_unknown_cmd_instaa():
|
|
|
|
return '''Error: Unknown command: instaa'''
|
|
|
|
|
|
|
|
|
|
|
|
def test_match(brew_unknown_cmd):
|
2015-04-25 02:35:26 +02:00
|
|
|
assert match(Command('brew inst', stderr=brew_unknown_cmd), None)
|
2015-04-23 17:00:57 +09:00
|
|
|
for command in brew_commands:
|
2015-04-25 02:35:26 +02:00
|
|
|
assert not match(Command('brew ' + command), None)
|
2015-04-23 17:00:57 +09:00
|
|
|
|
|
|
|
|
|
|
|
def test_get_new_command(brew_unknown_cmd, brew_unknown_cmd_instaa):
|
2015-04-25 02:35:26 +02:00
|
|
|
assert get_new_command(Command('brew inst', stderr=brew_unknown_cmd), None)\
|
2015-04-23 17:00:57 +09:00
|
|
|
== 'brew list'
|
|
|
|
|
2015-04-25 02:35:26 +02:00
|
|
|
assert get_new_command(Command('brew instaa', stderr=brew_unknown_cmd_instaa),
|
2015-04-23 17:00:57 +09:00
|
|
|
None) == 'brew install'
|