mirror of
https://github.com/nvbn/thefuck.git
synced 2025-09-18 19:22:32 +01:00
Merge pull request #110 from kimtree/support-brew
Support brew unknown command
This commit is contained in:
49
tests/rules/test_brew_install.py
Normal file
49
tests/rules/test_brew_install.py
Normal file
@@ -0,0 +1,49 @@
|
||||
import pytest
|
||||
from thefuck.types import Command
|
||||
from thefuck.rules.brew_install import match, get_new_command
|
||||
from thefuck.rules.brew_install import brew_formulas
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def brew_no_available_formula():
|
||||
return '''Error: No available formula for elsticsearch '''
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def brew_install_no_argument():
|
||||
return '''This command requires a formula argument'''
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def brew_already_installed():
|
||||
return '''Warning: git-2.3.5 already installed'''
|
||||
|
||||
|
||||
def _is_not_okay_to_test():
|
||||
if 'elasticsearch' not in brew_formulas:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
@pytest.mark.skipif(_is_not_okay_to_test(),
|
||||
reason='No need to run if there\'s no formula')
|
||||
def test_match(brew_no_available_formula, brew_already_installed,
|
||||
brew_install_no_argument):
|
||||
assert match(Command('brew install elsticsearch', '',
|
||||
brew_no_available_formula), None)
|
||||
assert not match(Command('brew install git', '',
|
||||
brew_already_installed), None)
|
||||
assert not match(Command('brew install', '', brew_install_no_argument),
|
||||
None)
|
||||
|
||||
|
||||
@pytest.mark.skipif(_is_not_okay_to_test(),
|
||||
reason='No need to run if there\'s no formula')
|
||||
def test_get_new_command(brew_no_available_formula):
|
||||
assert get_new_command(Command('brew install elsticsearch', '',
|
||||
brew_no_available_formula), None)\
|
||||
== 'brew install elasticsearch'
|
||||
|
||||
assert get_new_command(Command('brew install aa', '',
|
||||
brew_no_available_formula),
|
||||
None) != 'brew install aha'
|
28
tests/rules/test_brew_unknown_command.py
Normal file
28
tests/rules/test_brew_unknown_command.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import pytest
|
||||
from thefuck.types import Command
|
||||
from thefuck.rules.brew_unknown_command import match, get_new_command
|
||||
from thefuck.rules.brew_unknown_command import brew_commands
|
||||
|
||||
|
||||
@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):
|
||||
assert match(Command('brew inst', '', brew_unknown_cmd), None)
|
||||
for command in brew_commands:
|
||||
assert not match(Command('brew ' + command, '', ''), None)
|
||||
|
||||
|
||||
def test_get_new_command(brew_unknown_cmd, brew_unknown_cmd_instaa):
|
||||
assert get_new_command(Command('brew inst', '', brew_unknown_cmd), None)\
|
||||
== 'brew list'
|
||||
|
||||
assert get_new_command(Command('brew instaa', '', brew_unknown_cmd_instaa),
|
||||
None) == 'brew install'
|
Reference in New Issue
Block a user