2015-04-25 02:54:39 +02:00
|
|
|
import pytest
|
2015-04-22 16:22:10 +02:00
|
|
|
from thefuck.rules.rm_root import match, get_new_command
|
2015-04-25 02:54:39 +02:00
|
|
|
from tests.utils import Command
|
2015-04-22 16:22:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_match():
|
2015-04-25 02:54:39 +02:00
|
|
|
assert match(Command(script='rm -rf /',
|
2015-09-07 13:00:29 +03:00
|
|
|
stderr='add --no-preserve-root'))
|
2015-04-25 02:54:39 +02:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('command', [
|
|
|
|
Command(script='ls', stderr='add --no-preserve-root'),
|
|
|
|
Command(script='rm --no-preserve-root /', stderr='add --no-preserve-root'),
|
|
|
|
Command(script='rm -rf /', stderr='')])
|
|
|
|
def test_not_match(command):
|
2015-09-07 13:00:29 +03:00
|
|
|
assert not match(command)
|
2015-04-22 16:22:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_get_new_command():
|
2016-10-06 14:51:22 -04:00
|
|
|
assert (get_new_command(Command(script='rm -rf /'))
|
|
|
|
== 'rm -rf / --no-preserve-root')
|