1
0
mirror of https://github.com/nvbn/thefuck.git synced 2024-10-06 02:41:10 +01:00
thefuck/tests/rules/test_ln_no_hard_link.py
2016-03-02 17:57:53 +01:00

46 lines
1.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from thefuck.rules.ln_no_hard_link import match, get_new_command
from tests.utils import Command
def test_match():
err = "hard link not allowed for directory"
assert not match(Command())
cmd1 = Command("ln barDir barLink", stderr="ln: barDir: {}".format(err))
assert match(cmd1)
cmd2 = Command("sudo ln a b", stderr="ln: a: {}".format(err))
assert match(cmd2)
cmd3 = Command("ln a b", stderr="... hard link")
assert not match(cmd3)
cmd4 = Command("sudo ln a b", stderr="... hard link")
assert not match(cmd4)
cmd5 = Command("a b", stderr=err)
assert not match(cmd5)
cmd6 = Command("sudo ln -nbi a b", stderr="ln: a: {}".format(err))
assert match(cmd6)
def test_get_new_command():
cmd1 = Command("ln barDir barLink")
assert get_new_command(cmd1) == "ln -s barDir barLink"
cmd2 = Command("sudo ln barDir barLink")
assert get_new_command(cmd2) == "sudo ln -s barDir barLink"
cmd3 = Command("sudo ln -nbi a b")
assert get_new_command(cmd3) == "sudo ln -s -nbi a b"
cmd4 = Command("ln -nbi a b && ls")
assert get_new_command(cmd4) == "ln -s -nbi a b && ls"
cmd5 = Command("ln a ln")
assert get_new_command(cmd5) == "ln -s a ln"
cmd6 = Command("sudo ln a ln")
assert get_new_command(cmd6) == "sudo ln -s a ln"