2015-08-12 18:10:26 +02:00
|
|
|
import pytest
|
|
|
|
from mock import patch
|
|
|
|
from thefuck.rules import pacman_not_found
|
|
|
|
from thefuck.rules.pacman_not_found import match, get_new_command
|
2017-08-31 17:58:56 +02:00
|
|
|
from thefuck.types import Command
|
2015-08-12 18:10:26 +02:00
|
|
|
|
|
|
|
PKGFILE_OUTPUT_LLC = '''extra/llvm 3.6.0-5 /usr/bin/llc
|
|
|
|
extra/llvm35 3.5.2-13/usr/bin/llc'''
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.skipif(not getattr(pacman_not_found, 'enabled_by_default', True),
|
|
|
|
reason='Skip if pacman is not available')
|
|
|
|
@pytest.mark.parametrize('command', [
|
2019-05-21 18:49:04 +00:00
|
|
|
Command('yay -S llc', 'error: target not found: llc'),
|
2022-03-27 22:06:40 +02:00
|
|
|
Command('pikaur -S llc', 'error: target not found: llc'),
|
2017-08-31 17:58:56 +02:00
|
|
|
Command('yaourt -S llc', 'error: target not found: llc'),
|
|
|
|
Command('pacman llc', 'error: target not found: llc'),
|
|
|
|
Command('sudo pacman llc', 'error: target not found: llc')])
|
2015-08-12 18:10:26 +02:00
|
|
|
def test_match(command):
|
2015-09-07 13:00:29 +03:00
|
|
|
assert match(command)
|
2015-08-12 18:10:26 +02:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('command', [
|
2019-05-21 18:49:04 +00:00
|
|
|
Command('yay -S llc', 'error: target not found: llc'),
|
2022-03-27 22:06:40 +02:00
|
|
|
Command('pikaur -S llc', 'error: target not found: llc'),
|
2017-08-31 17:58:56 +02:00
|
|
|
Command('yaourt -S llc', 'error: target not found: llc'),
|
|
|
|
Command('pacman llc', 'error: target not found: llc'),
|
|
|
|
Command('sudo pacman llc', 'error: target not found: llc')])
|
2015-08-25 14:09:47 +03:00
|
|
|
@patch('thefuck.specific.archlinux.subprocess')
|
2015-08-12 18:10:26 +02:00
|
|
|
def test_match_mocked(subp_mock, command):
|
|
|
|
subp_mock.check_output.return_value = PKGFILE_OUTPUT_LLC
|
2015-09-07 13:00:29 +03:00
|
|
|
assert match(command)
|
2015-08-12 18:10:26 +02:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.skipif(not getattr(pacman_not_found, 'enabled_by_default', True),
|
|
|
|
reason='Skip if pacman is not available')
|
|
|
|
@pytest.mark.parametrize('command, fixed', [
|
2019-05-21 18:49:04 +00:00
|
|
|
(Command('yay -S llc', 'error: target not found: llc'), ['yay -S extra/llvm', 'yay -S extra/llvm35']),
|
2022-03-27 22:06:40 +02:00
|
|
|
(Command('pikaur -S llc', 'error: target not found: llc'), ['pikaur -S extra/llvm', 'pikaur -S extra/llvm35']),
|
2017-08-31 17:58:56 +02:00
|
|
|
(Command('yaourt -S llc', 'error: target not found: llc'), ['yaourt -S extra/llvm', 'yaourt -S extra/llvm35']),
|
|
|
|
(Command('pacman -S llc', 'error: target not found: llc'), ['pacman -S extra/llvm', 'pacman -S extra/llvm35']),
|
|
|
|
(Command('sudo pacman -S llc', 'error: target not found: llc'), ['sudo pacman -S extra/llvm', 'sudo pacman -S extra/llvm35'])])
|
2015-08-12 18:10:26 +02:00
|
|
|
def test_get_new_command(command, fixed):
|
2015-09-07 13:00:29 +03:00
|
|
|
assert get_new_command(command) == fixed
|
2015-08-12 18:10:26 +02:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('command, fixed', [
|
2019-05-21 18:49:04 +00:00
|
|
|
(Command('yay -S llc', 'error: target not found: llc'), ['yay -S extra/llvm', 'yay -S extra/llvm35']),
|
2022-03-27 22:06:40 +02:00
|
|
|
(Command('pikaur -S llc', 'error: target not found: llc'), ['pikaur -S extra/llvm', 'pikaur -S extra/llvm35']),
|
2017-08-31 17:58:56 +02:00
|
|
|
(Command('yaourt -S llc', 'error: target not found: llc'), ['yaourt -S extra/llvm', 'yaourt -S extra/llvm35']),
|
|
|
|
(Command('pacman -S llc', 'error: target not found: llc'), ['pacman -S extra/llvm', 'pacman -S extra/llvm35']),
|
|
|
|
(Command('sudo pacman -S llc', 'error: target not found: llc'), ['sudo pacman -S extra/llvm', 'sudo pacman -S extra/llvm35'])])
|
2015-08-25 14:09:47 +03:00
|
|
|
@patch('thefuck.specific.archlinux.subprocess')
|
2015-08-12 18:10:26 +02:00
|
|
|
def test_get_new_command_mocked(subp_mock, command, fixed):
|
|
|
|
subp_mock.check_output.return_value = PKGFILE_OUTPUT_LLC
|
2015-09-07 13:00:29 +03:00
|
|
|
assert get_new_command(command) == fixed
|