2016-09-30 15:31:25 -04:00
|
|
|
import pytest
|
2017-08-31 17:58:56 +02:00
|
|
|
from thefuck.types import Command
|
2016-09-30 15:31:25 -04:00
|
|
|
from thefuck.rules.brew_link import get_new_command, match
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
2017-08-31 17:58:56 +02:00
|
|
|
def output():
|
2016-09-30 15:31:25 -04:00
|
|
|
return ("Error: Could not symlink bin/gcp\n"
|
2016-10-05 11:12:06 -04:00
|
|
|
"Target /usr/local/bin/gcp\n"
|
|
|
|
"already exists. You may want to remove it:\n"
|
2016-10-06 15:16:43 -04:00
|
|
|
" rm '/usr/local/bin/gcp'\n"
|
2016-10-05 11:12:06 -04:00
|
|
|
"\n"
|
|
|
|
"To force the link and overwrite all conflicting files:\n"
|
2016-10-06 15:16:43 -04:00
|
|
|
" brew link --overwrite coreutils\n"
|
2016-10-05 11:12:06 -04:00
|
|
|
"\n"
|
|
|
|
"To list all files that would be deleted:\n"
|
2016-10-06 15:16:43 -04:00
|
|
|
" brew link --overwrite --dry-run coreutils\n")
|
2016-09-30 15:31:25 -04:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def new_command(formula):
|
|
|
|
return 'brew link --overwrite --dry-run {}'.format(formula)
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('script', ['brew link coreutils', 'brew ln coreutils'])
|
2017-08-31 17:58:56 +02:00
|
|
|
def test_match(output, script):
|
|
|
|
assert match(Command(script, output))
|
2016-09-30 15:31:25 -04:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('script', ['brew link coreutils'])
|
|
|
|
def test_not_match(script):
|
2017-08-31 17:58:56 +02:00
|
|
|
assert not match(Command(script, ''))
|
2016-09-30 15:31:25 -04:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('script, formula, ', [('brew link coreutils', 'coreutils')])
|
2017-08-31 17:58:56 +02:00
|
|
|
def test_get_new_command(output, new_command, script, formula):
|
|
|
|
assert get_new_command(Command(script, output)) == new_command
|