1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-04-18 00:30:44 +01:00
thefuck/tests/rules/test_nodenv_no_such_command.py
2020-07-06 14:33:32 +03:00

38 lines
1.1 KiB
Python

import pytest
from thefuck.rules.nodenv_no_such_command import get_new_command, match
from thefuck.types import Command
@pytest.fixture
def output(nodenv_cmd):
return "nodenv: no such command `{}'".format(nodenv_cmd)
@pytest.mark.parametrize('script, nodenv_cmd', [
('nodenv globe', 'globe'),
('nodenv intall 3.8.0', 'intall'),
('nodenv list', 'list'),
])
def test_match(script, nodenv_cmd, output):
assert match(Command(script, output=output))
@pytest.mark.parametrize('script, output', [
('nodenv global', 'system'),
('nodenv versions', ' 3.7.0\n 3.7.1\n* 3.7.2\n'),
('nodenv install --list', ' 3.7.0\n 3.7.1\n 3.7.2\n'),
])
def test_not_match(script, output):
assert not match(Command(script, output=output))
@pytest.mark.parametrize('script, nodenv_cmd, result', [
('nodenv globe', 'globe', 'nodenv global'),
('nodenv intall 3.8.0', 'intall', 'nodenv install 3.8.0'),
('nodenv list', 'list', 'nodenv install --list'),
('nodenv remove 3.8.0', 'remove', 'nodenv uninstall 3.8.0'),
])
def test_get_new_command(script, nodenv_cmd, output, result):
assert result in get_new_command(Command(script, output))