2016-04-20 22:27:39 -03:00
|
|
|
import pytest
|
2017-08-31 17:58:56 +02:00
|
|
|
from thefuck.types import Command
|
2016-04-20 22:27:39 -03:00
|
|
|
from thefuck.rules.brew_update_formula import get_new_command, match
|
|
|
|
|
|
|
|
|
2017-10-15 16:39:40 +02:00
|
|
|
output = ("Error: This command updates brew itself, and does not take formula"
|
2022-06-28 18:28:38 +02:00
|
|
|
" names.\nUse `brew upgrade thefuck`.")
|
2016-04-20 22:27:39 -03:00
|
|
|
|
|
|
|
|
2017-10-15 16:39:40 +02:00
|
|
|
def test_match():
|
|
|
|
command = Command('brew update thefuck', output)
|
|
|
|
assert match(command)
|
2016-04-20 22:27:39 -03:00
|
|
|
|
|
|
|
|
2017-10-15 16:39:40 +02:00
|
|
|
@pytest.mark.parametrize('script', [
|
|
|
|
'brew upgrade foo',
|
|
|
|
'brew update'])
|
2016-04-20 22:27:39 -03:00
|
|
|
def test_not_match(script):
|
2017-08-31 17:58:56 +02:00
|
|
|
assert not match(Command(script, ''))
|
2016-04-20 22:27:39 -03:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('script, formula, ', [
|
2017-10-15 16:39:40 +02:00
|
|
|
('brew update foo', 'foo'),
|
|
|
|
('brew update bar zap', 'bar zap')])
|
|
|
|
def test_get_new_command(script, formula):
|
|
|
|
command = Command(script, output)
|
|
|
|
new_command = 'brew upgrade {}'.format(formula)
|
|
|
|
assert get_new_command(command) == new_command
|