2015-04-25 02:54:39 +02:00
|
|
|
import pytest
|
2015-04-24 08:52:39 +02:00
|
|
|
from thefuck.rules.cd_mkdir import match, get_new_command
|
2015-04-25 02:54:39 +02:00
|
|
|
from tests.utils import Command
|
2015-04-24 08:52:39 +02:00
|
|
|
|
|
|
|
|
2015-04-25 02:54:39 +02:00
|
|
|
@pytest.mark.parametrize('command', [
|
|
|
|
Command(script='cd foo', stderr='cd: foo: No such file or directory'),
|
|
|
|
Command(script='cd foo/bar/baz',
|
|
|
|
stderr='cd: foo: No such file or directory'),
|
|
|
|
Command(script='cd foo/bar/baz', stderr='cd: can\'t cd to foo/bar/baz')])
|
|
|
|
def test_match(command):
|
2015-09-07 13:00:29 +03:00
|
|
|
assert match(command)
|
2015-04-24 08:52:39 +02:00
|
|
|
|
|
|
|
|
2015-04-25 02:54:39 +02:00
|
|
|
@pytest.mark.parametrize('command', [
|
|
|
|
Command(script='cd foo', stderr=''), Command()])
|
|
|
|
def test_not_match(command):
|
2015-09-07 13:00:29 +03:00
|
|
|
assert not match(command)
|
2015-04-25 02:54:39 +02:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('command, new_command', [
|
|
|
|
(Command('cd foo'), 'mkdir -p foo && cd foo'),
|
|
|
|
(Command('cd foo/bar/baz'), 'mkdir -p foo/bar/baz && cd foo/bar/baz')])
|
|
|
|
def test_get_new_command(command, new_command):
|
2015-09-07 13:00:29 +03:00
|
|
|
assert get_new_command(command) == new_command
|