2015-08-25 14:09:47 +03:00
|
|
|
import pytest
|
|
|
|
from thefuck.specific.git import git_support
|
2017-08-31 17:58:56 +02:00
|
|
|
from thefuck.types import Command
|
2015-08-25 14:09:47 +03:00
|
|
|
|
|
|
|
|
2017-08-31 17:58:56 +02:00
|
|
|
@pytest.mark.parametrize('called, command, output', [
|
2015-08-25 14:09:47 +03:00
|
|
|
('git co', 'git checkout', "19:22:36.299340 git.c:282 trace: alias expansion: co => 'checkout'"),
|
|
|
|
('git com file', 'git commit --verbose file',
|
2021-07-13 22:33:00 +02:00
|
|
|
"19:23:25.470911 git.c:282 trace: alias expansion: com => 'commit' '--verbose'"),
|
|
|
|
('git com -m "Initial commit"', 'git commit -m "Initial commit"',
|
|
|
|
"19:22:36.299340 git.c:282 trace: alias expansion: com => 'commit'"),
|
|
|
|
('git br -d some_branch', 'git branch -d some_branch',
|
|
|
|
"19:22:36.299340 git.c:282 trace: alias expansion: br => 'branch'")])
|
2017-08-31 17:58:56 +02:00
|
|
|
def test_git_support(called, command, output):
|
2015-08-25 14:09:47 +03:00
|
|
|
@git_support
|
2015-09-07 13:00:29 +03:00
|
|
|
def fn(command):
|
|
|
|
return command.script
|
2015-08-25 14:09:47 +03:00
|
|
|
|
2017-08-31 17:58:56 +02:00
|
|
|
assert fn(Command(called, output)) == command
|
2015-08-25 14:09:47 +03:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('command, is_git', [
|
|
|
|
('git pull', True),
|
|
|
|
('hub pull', True),
|
|
|
|
('git push --set-upstream origin foo', True),
|
|
|
|
('hub push --set-upstream origin foo', True),
|
|
|
|
('ls', False),
|
|
|
|
('cat git', False),
|
|
|
|
('cat hub', False)])
|
2021-08-16 22:44:13 +02:00
|
|
|
@pytest.mark.parametrize('output', ['', None])
|
|
|
|
def test_git_support_match(command, is_git, output):
|
2015-08-25 14:09:47 +03:00
|
|
|
@git_support
|
2015-09-07 13:00:29 +03:00
|
|
|
def fn(command):
|
|
|
|
return True
|
2015-08-25 14:09:47 +03:00
|
|
|
|
2021-08-16 22:44:13 +02:00
|
|
|
assert fn(Command(command, output)) == is_git
|