2017-03-26 15:51:59 -04:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2015-07-22 04:44:37 +03:00
|
|
|
import pytest
|
|
|
|
from tests.utils import Command
|
|
|
|
from thefuck.rules.heroku_not_command import match, get_new_command
|
|
|
|
|
|
|
|
|
2017-03-26 15:51:59 -04:00
|
|
|
suggest_stderr = '''
|
|
|
|
▸ log is not a heroku command.
|
|
|
|
▸ Perhaps you meant logs?
|
|
|
|
▸ Run heroku _ to run heroku logs.
|
|
|
|
▸ Run heroku help for a list of available commands.'''
|
2015-07-22 04:44:37 +03:00
|
|
|
|
|
|
|
|
2017-03-26 15:51:59 -04:00
|
|
|
@pytest.mark.parametrize('cmd', ['log'])
|
2015-07-22 04:44:37 +03:00
|
|
|
def test_match(cmd):
|
|
|
|
assert match(
|
2017-03-26 15:51:59 -04:00
|
|
|
Command('heroku {}'.format(cmd), stderr=suggest_stderr))
|
2015-07-22 04:44:37 +03:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('script, stderr', [
|
2017-03-26 15:51:59 -04:00
|
|
|
('cat log', suggest_stderr)])
|
2015-07-22 04:44:37 +03:00
|
|
|
def test_not_match(script, stderr):
|
2015-09-07 13:00:29 +03:00
|
|
|
assert not match(Command(script, stderr=stderr))
|
2015-07-22 04:44:37 +03:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('cmd, result', [
|
2017-03-26 15:51:59 -04:00
|
|
|
('log', 'heroku logs')])
|
2015-07-22 04:44:37 +03:00
|
|
|
def test_get_new_command(cmd, result):
|
2017-03-26 15:51:59 -04:00
|
|
|
command = Command('heroku {}'.format(cmd), stderr=suggest_stderr)
|
2015-09-07 13:00:29 +03:00
|
|
|
assert get_new_command(command) == result
|