2018-01-05 21:24:43 +00:00
|
|
|
import pytest
|
|
|
|
from thefuck.rules.git_commit_amend import match, get_new_command
|
|
|
|
from thefuck.types import Command
|
|
|
|
|
|
|
|
|
2020-03-24 10:46:35 +00:00
|
|
|
@pytest.mark.parametrize('script, code, output', [
|
|
|
|
('git commit -m "test"', '0', 'test output'),
|
|
|
|
('git commit', '0', '')])
|
|
|
|
def test_match(monkeypatch, output, code, script):
|
|
|
|
monkeypatch.setenv('TF_STATUS', code)
|
2018-01-05 21:24:43 +00:00
|
|
|
assert match(Command(script, output))
|
|
|
|
|
|
|
|
|
2020-03-24 10:46:35 +00:00
|
|
|
@pytest.mark.parametrize('script, code', [
|
|
|
|
('git branch foo', '0'),
|
|
|
|
('git checkout feature/test_commit', '0'),
|
|
|
|
('git push', '0'),
|
|
|
|
('git commit -m', '1')])
|
|
|
|
def test_not_match(monkeypatch, script, code):
|
|
|
|
monkeypatch.setenv('TF_STATUS', code)
|
2018-01-05 21:24:43 +00:00
|
|
|
assert not match(Command(script, ''))
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('script', [
|
|
|
|
('git commit -m "test commit"'),
|
|
|
|
('git commit')])
|
|
|
|
def test_get_new_command(script):
|
|
|
|
assert get_new_command(Command(script, '')) == 'git commit --amend'
|