2017-03-26 15:51:59 -04:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2015-07-22 04:44:37 +03:00
|
|
|
import pytest
|
2017-08-31 17:58:56 +02:00
|
|
|
from thefuck.types import Command
|
2015-07-22 04:44:37 +03:00
|
|
|
from thefuck.rules.heroku_not_command import match, get_new_command
|
|
|
|
|
|
|
|
|
2017-08-31 17:58:56 +02:00
|
|
|
suggest_output = '''
|
2017-03-26 15:51:59 -04:00
|
|
|
▸ 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-08-31 17:58:56 +02:00
|
|
|
Command('heroku {}'.format(cmd), suggest_output))
|
2015-07-22 04:44:37 +03:00
|
|
|
|
|
|
|
|
2017-08-31 17:58:56 +02:00
|
|
|
@pytest.mark.parametrize('script, output', [
|
|
|
|
('cat log', suggest_output)])
|
|
|
|
def test_not_match(script, output):
|
|
|
|
assert not match(Command(script, output))
|
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-08-31 17:58:56 +02:00
|
|
|
command = Command('heroku {}'.format(cmd), suggest_output)
|
2015-09-07 13:00:29 +03:00
|
|
|
assert get_new_command(command) == result
|