mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-19 04:21:14 +00:00
a696461cd3
* apt_list_upgradable: Prepend sudo to suggestion if used in command * Add apt_upgrade rule This suggests `apt upgrade` after `apt list --upgradable` if there are packages to upgrade. It pairs well with the `apt_list_upgradable` rule, which suggests `apt list --upgradable` after `apt update` if there are packages to upgrade. * Add apt_upgrade rule to README
37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
import pytest
|
|
from thefuck.rules.apt_upgrade import get_new_command, match
|
|
from thefuck.types import Command
|
|
|
|
match_output = '''
|
|
Listing... Done
|
|
heroku/stable 6.15.2-1 amd64 [upgradable from: 6.14.43-1]
|
|
resolvconf/zesty-updates,zesty-updates 1.79ubuntu4.1 all [upgradable from: 1.79ubuntu4]
|
|
squashfs-tools/zesty-updates 1:4.3-3ubuntu2.17.04.1 amd64 [upgradable from: 1:4.3-3ubuntu2]
|
|
unattended-upgrades/zesty-updates,zesty-updates 0.93.1ubuntu2.4 all [upgradable from: 0.93.1ubuntu2.3]
|
|
'''
|
|
|
|
no_match_output = '''
|
|
Listing... Done
|
|
'''
|
|
|
|
|
|
def test_match():
|
|
assert match(Command('apt list --upgradable', match_output))
|
|
assert match(Command('sudo apt list --upgradable', match_output))
|
|
|
|
|
|
@pytest.mark.parametrize('command', [
|
|
Command('apt list --upgradable', no_match_output),
|
|
Command('sudo apt list --upgradable', no_match_output)
|
|
])
|
|
def test_not_match(command):
|
|
assert not match(command)
|
|
|
|
|
|
def test_get_new_command():
|
|
new_command = get_new_command(Command('apt list --upgradable', match_output))
|
|
assert new_command == 'apt upgrade'
|
|
|
|
new_command = get_new_command(Command('sudo apt list --upgradable', match_output))
|
|
assert new_command == 'sudo apt upgrade'
|