2015-04-25 02:54:39 +02:00
|
|
|
import pytest
|
2015-04-20 12:32:32 +02:00
|
|
|
from thefuck.rules.rm_dir import match, get_new_command
|
2017-08-31 17:58:56 +02:00
|
|
|
from thefuck.types import Command
|
2015-04-20 12:32:32 +02:00
|
|
|
|
|
|
|
|
2015-04-25 02:54:39 +02:00
|
|
|
@pytest.mark.parametrize('command', [
|
2017-08-31 17:58:56 +02:00
|
|
|
Command('rm foo', 'rm: foo: is a directory'),
|
|
|
|
Command('rm foo', 'rm: foo: Is a directory'),
|
|
|
|
Command('hdfs dfs -rm foo', 'rm: `foo`: Is a directory'),
|
|
|
|
Command('./bin/hdfs dfs -rm foo', 'rm: `foo`: Is a directory'),
|
2015-11-15 18:02:37 +01:00
|
|
|
])
|
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-25 02:54:39 +02:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('command', [
|
2017-08-31 17:58:56 +02:00
|
|
|
Command('rm foo', ''),
|
|
|
|
Command('hdfs dfs -rm foo', ''),
|
|
|
|
Command('./bin/hdfs dfs -rm foo', ''),
|
|
|
|
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 12:32:32 +02:00
|
|
|
|
|
|
|
|
2015-08-21 15:48:54 +01:00
|
|
|
@pytest.mark.parametrize('command, new_command', [
|
2017-08-31 17:58:56 +02:00
|
|
|
(Command('rm foo', ''), 'rm -rf foo'),
|
|
|
|
(Command('hdfs dfs -rm foo', ''), 'hdfs dfs -rm -r foo'),
|
2015-11-15 18:02:37 +01:00
|
|
|
])
|
2015-08-21 15:48:54 +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
|