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
|
2017-08-31 17:58:56 +02:00
|
|
|
from thefuck.types import Command
|
2015-04-24 08:52:39 +02:00
|
|
|
|
|
|
|
|
2015-04-25 02:54:39 +02:00
|
|
|
@pytest.mark.parametrize('command', [
|
2017-08-31 17:58:56 +02:00
|
|
|
Command('cd foo', 'cd: foo: No such file or directory'),
|
|
|
|
Command('cd foo/bar/baz',
|
|
|
|
'cd: foo: No such file or directory'),
|
2018-02-23 20:45:36 +01:00
|
|
|
Command('cd foo/bar/baz', 'cd: can\'t cd to foo/bar/baz'),
|
|
|
|
Command('cd /foo/bar/', 'cd: The directory "/foo/bar/" does not exist')])
|
2015-04-25 02:54:39 +02:00
|
|
|
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', [
|
2017-08-31 17:58:56 +02:00
|
|
|
Command('cd foo', ''), Command('', '')])
|
2015-04-25 02:54:39 +02:00
|
|
|
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', [
|
2017-08-31 17:58:56 +02:00
|
|
|
(Command('cd foo', ''), 'mkdir -p foo && cd foo'),
|
|
|
|
(Command('cd foo/bar/baz', ''), 'mkdir -p foo/bar/baz && cd foo/bar/baz')])
|
2015-04-25 02:54:39 +02:00
|
|
|
def test_get_new_command(command, new_command):
|
2015-09-07 13:00:29 +03:00
|
|
|
assert get_new_command(command) == new_command
|