2015-04-23 17:00:57 +09:00
|
|
|
import pytest
|
|
|
|
from thefuck.rules.brew_unknown_command import match, get_new_command
|
2015-08-26 19:46:23 +02:00
|
|
|
from thefuck.rules.brew_unknown_command import _brew_commands
|
2017-08-31 17:58:56 +02:00
|
|
|
from thefuck.types import Command
|
2015-04-23 17:00:57 +09:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def brew_unknown_cmd():
|
|
|
|
return '''Error: Unknown command: inst'''
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
2015-04-29 15:18:48 +09:00
|
|
|
def brew_unknown_cmd2():
|
2015-04-23 17:00:57 +09:00
|
|
|
return '''Error: Unknown command: instaa'''
|
|
|
|
|
|
|
|
|
|
|
|
def test_match(brew_unknown_cmd):
|
2017-08-31 17:58:56 +02:00
|
|
|
assert match(Command('brew inst', brew_unknown_cmd))
|
2015-08-26 19:46:23 +02:00
|
|
|
for command in _brew_commands():
|
2017-08-31 17:58:56 +02:00
|
|
|
assert not match(Command('brew ' + command, ''))
|
2015-04-23 17:00:57 +09:00
|
|
|
|
|
|
|
|
2015-04-29 15:18:48 +09:00
|
|
|
def test_get_new_command(brew_unknown_cmd, brew_unknown_cmd2):
|
2017-08-31 17:58:56 +02:00
|
|
|
assert (get_new_command(Command('brew inst', brew_unknown_cmd))
|
2016-10-06 14:51:22 -04:00
|
|
|
== ['brew list', 'brew install', 'brew uninstall'])
|
2015-04-23 17:00:57 +09:00
|
|
|
|
2017-08-31 17:58:56 +02:00
|
|
|
cmds = get_new_command(Command('brew instaa', brew_unknown_cmd2))
|
2015-08-27 10:12:31 +02:00
|
|
|
assert 'brew install' in cmds
|
|
|
|
assert 'brew uninstall' in cmds
|