1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-02-20 20:09:07 +00:00

Not matched unit tests, code style.

This commit is contained in:
Michael Lee 2015-08-20 09:41:01 +01:00
parent 004c0d06eb
commit 7cb0388ed0
2 changed files with 11 additions and 1 deletions

View File

@ -13,6 +13,15 @@ def test_match(command):
assert match(command, None)
@pytest.mark.parametrize('command', [
Command(script='vagrant ssh', stderr=''),
Command(script='vagrant ssh jeff', stderr='The machine with the name \'jeff\' was not found configured for this Vagrant environment.'),
Command(script='vagrant ssh', stderr='A Vagrant environment or target machine is required to run this command. Run `vagrant init` to create a new Vagrant environment. Or, get an ID of a target machine from `vagrant global-status` to run this command on. A final option is to change to a directory with a Vagrantfile and to try again.'),
Command()])
def test_not_match(command):
assert not match(command, None)
@pytest.mark.parametrize('command, new_command', [
(Command(script='vagrant ssh', stderr='VM must be running to open SSH connection. Run `vagrant up`\nto start the virtual machine.'), 'vagrant up && vagrant ssh'),
(Command(script='vagrant ssh devbox', stderr='VM must be running to open SSH connection. Run `vagrant up`\nto start the virtual machine.'), 'vagrant up devbox && vagrant ssh devbox'),

View File

@ -4,9 +4,10 @@ from thefuck import shells
def match(command, settings):
return command.script.startswith('vagrant ') and 'run `vagrant up`' in command.stderr.lower()
def get_new_command(command, settings):
cmds = command.script.split(' ')
machine = ""
if len(cmds) >= 3:
machine = cmds[2]
return "vagrant up " + machine + " && " + command.script
return shells.and_("vagrant up " + machine, command.script)