2015-04-08 18:15:49 +02:00
|
|
|
import pytest
|
|
|
|
from thefuck.rules.git_push import match, get_new_command
|
2017-08-31 17:58:56 +02:00
|
|
|
from thefuck.types import Command
|
2015-04-08 18:15:49 +02:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
2017-08-31 17:58:56 +02:00
|
|
|
def output():
|
2015-04-08 18:15:49 +02:00
|
|
|
return '''fatal: The current branch master has no upstream branch.
|
|
|
|
To push the current branch and set the remote as upstream, use
|
|
|
|
|
|
|
|
git push --set-upstream origin master
|
|
|
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
2017-08-31 17:58:56 +02:00
|
|
|
def test_match(output):
|
|
|
|
assert match(Command('git push', output))
|
|
|
|
assert match(Command('git push master', output))
|
|
|
|
assert not match(Command('git push master', ''))
|
|
|
|
assert not match(Command('ls', output))
|
2015-04-08 18:15:49 +02:00
|
|
|
|
|
|
|
|
2017-08-31 17:58:56 +02:00
|
|
|
def test_get_new_command(output):
|
|
|
|
assert get_new_command(Command('git push', output))\
|
2015-04-08 18:15:49 +02:00
|
|
|
== "git push --set-upstream origin master"
|
2017-08-31 17:58:56 +02:00
|
|
|
assert get_new_command(Command('git push -u', output))\
|
2016-10-06 13:03:34 -04:00
|
|
|
== "git push --set-upstream origin master"
|
2017-08-31 17:58:56 +02:00
|
|
|
assert get_new_command(Command('git push -u origin', output))\
|
2016-09-30 16:11:46 -04:00
|
|
|
== "git push --set-upstream origin master"
|
2017-08-31 17:58:56 +02:00
|
|
|
assert get_new_command(Command('git push --set-upstream origin', output))\
|
2016-09-30 16:11:46 -04:00
|
|
|
== "git push --set-upstream origin master"
|
2017-08-31 17:58:56 +02:00
|
|
|
assert get_new_command(Command('git push --quiet', output))\
|
2016-08-19 22:24:02 +01:00
|
|
|
== "git push --set-upstream origin master --quiet"
|