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
|
2015-04-25 02:35:26 +02:00
|
|
|
from tests.utils import Command
|
2015-04-20 18:38:03 +02:00
|
|
|
|
|
|
|
|
2015-08-21 16:05:49 +01:00
|
|
|
@pytest.mark.parametrize('command', [
|
|
|
|
Command('mkdir foo/bar/baz', stderr='mkdir: foo/bar: No such file or directory'),
|
|
|
|
Command('./bin/hdfs dfs -mkdir foo/bar/baz', stderr='mkdir: `foo/bar/baz\': No such file or directory'),
|
|
|
|
Command('hdfs dfs -mkdir foo/bar/baz', stderr='mkdir: `foo/bar/baz\': No such file or directory')
|
|
|
|
])
|
|
|
|
def test_match(command):
|
|
|
|
assert match(command, None)
|
2015-04-25 02:54:39 +02:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('command', [
|
|
|
|
Command('mkdir foo/bar/baz'),
|
|
|
|
Command('mkdir foo/bar/baz', stderr='foo bar baz'),
|
2015-08-21 16:05:49 +01:00
|
|
|
Command('hdfs dfs -mkdir foo/bar/baz'),
|
|
|
|
Command('./bin/hdfs dfs -mkdir foo/bar/baz'),
|
2015-04-25 02:54:39 +02:00
|
|
|
Command()])
|
|
|
|
def test_not_match(command):
|
|
|
|
assert not match(command, None)
|
2015-04-20 18:38:03 +02:00
|
|
|
|
|
|
|
|
2015-08-21 16:05:49 +01:00
|
|
|
@pytest.mark.parametrize('command, new_command', [
|
|
|
|
(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')])
|
|
|
|
def test_get_new_command(command, new_command):
|
|
|
|
assert get_new_command(command, None) == new_command
|
|
|
|
|