diff --git a/tests/rules/test_go_run.py b/tests/rules/test_go_run.py new file mode 100644 index 00000000..05745054 --- /dev/null +++ b/tests/rules/test_go_run.py @@ -0,0 +1,17 @@ +import pytest +from thefuck.rules.go_run import match, get_new_command +from tests.utils import Command + + +@pytest.mark.parametrize('command', [ + Command(script='go run foo'), + Command(script='go run bar')]) +def test_match(command): + assert match(command, None) + + +@pytest.mark.parametrize('command, new_command', [ + (Command('go run foo'), 'go run foo.go'), + (Command('go run bar'), 'go run bar.go')]) +def test_get_new_command(command, new_command): + assert get_new_command(command, None) == new_command diff --git a/thefuck/rules/go_run.py b/thefuck/rules/go_run.py new file mode 100644 index 00000000..79eedc50 --- /dev/null +++ b/thefuck/rules/go_run.py @@ -0,0 +1,14 @@ +# Appends .go when compiling go files +# +# Example: +# > go run foo +# error: go run: no go files listed +# +# + +def match(command, settings): + return (command.script.startswith ('go run ') + and not command.script.endswith('.go')) + +def get_new_command(command, settings): + return command.script + '.go'