2015-04-25 02:54:39 +02:00
|
|
|
import pytest
|
2015-04-20 18:38:03 +02:00
|
|
|
from thefuck.rules.mkdir_p import match, get_new_command
|
2017-08-31 17:58:56 +02:00
|
|
|
from thefuck.types import Command
|
2015-04-20 18:38:03 +02:00
|
|
|
|
|
|
|
|
2015-08-21 16:05:49 +01:00
|
|
|
@pytest.mark.parametrize('command', [
|
2017-08-31 17:58:56 +02:00
|
|
|
Command('mkdir foo/bar/baz', 'mkdir: foo/bar: No such file or directory'),
|
|
|
|
Command('./bin/hdfs dfs -mkdir foo/bar/baz', 'mkdir: `foo/bar/baz\': No such file or directory'),
|
|
|
|
Command('hdfs dfs -mkdir foo/bar/baz', 'mkdir: `foo/bar/baz\': No such file or directory')
|
2015-11-15 18:02:37 +01:00
|
|
|
])
|
2015-08-21 16:05:49 +01:00
|
|
|
def test_match(command):
|
2015-09-07 13:00:29 +03:00
|
|
|
assert match(command)
|
2015-04-25 02:54:39 +02:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('command', [
|
2017-08-31 17:58:56 +02:00
|
|
|
Command('mkdir foo/bar/baz', ''),
|
|
|
|
Command('mkdir foo/bar/baz', 'foo bar baz'),
|
|
|
|
Command('hdfs dfs -mkdir foo/bar/baz', ''),
|
|
|
|
Command('./bin/hdfs dfs -mkdir foo/bar/baz', ''),
|
|
|
|
Command('', ''),
|
2015-11-15 18:02:37 +01:00
|
|
|
])
|
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-20 18:38:03 +02:00
|
|
|
|
|
|
|
|
2015-08-21 16:05:49 +01:00
|
|
|
@pytest.mark.parametrize('command, new_command', [
|
2017-08-31 17:58:56 +02:00
|
|
|
(Command('mkdir foo/bar/baz', ''), 'mkdir -p foo/bar/baz'),
|
|
|
|
(Command('hdfs dfs -mkdir foo/bar/baz', ''), 'hdfs dfs -mkdir -p foo/bar/baz'),
|
|
|
|
(Command('./bin/hdfs dfs -mkdir foo/bar/baz', ''), './bin/hdfs dfs -mkdir -p foo/bar/baz'),
|
2015-11-15 18:02:37 +01:00
|
|
|
])
|
2015-08-21 16:05:49 +01:00
|
|
|
def test_get_new_command(command, new_command):
|
2015-09-07 13:00:29 +03:00
|
|
|
assert get_new_command(command) == new_command
|