1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-01-31 18:21:10 +00:00
thefuck/tests/rules/test_gcloud_cli.py

59 lines
2.1 KiB
Python
Raw Normal View History

2020-04-28 14:11:51 +00:00
import pytest
from thefuck.rules.gcloud_cli import match, get_new_command
from thefuck.types import Command
no_suggestions = '''\
ERROR: (gcloud) Command name argument expected.
'''
misspelled_command = '''\
ERROR: (gcloud) Invalid choice: 'comute'.
Usage: gcloud [optional flags] <group | command>
group may be access-context-manager | ai-platform | alpha | app |
asset | auth | beta | bigtable | builds | components |
composer | compute | config | container | dataflow |
dataproc | datastore | debug | deployment-manager |
dns | domains | endpoints | filestore | firebase |
functions | iam | iot | kms | logging | ml |
ml-engine | organizations | projects | pubsub | redis |
resource-manager | scheduler | services | source |
spanner | sql | tasks | topic
command may be docker | feedback | help | info | init | version
For detailed information on this command and its flags, run:
gcloud --help
'''
misspelled_subcommand = '''\
ERROR: (gcloud.compute) Invalid choice: 'instance'.
Maybe you meant:
gcloud compute instance-groups
gcloud compute instance-templates
gcloud compute instances
gcloud compute target-instances
To search the help text of gcloud commands, run:
gcloud help -- SEARCH_TERMS
'''
2020-05-09 16:21:55 +01:00
2020-04-28 14:11:51 +00:00
@pytest.mark.parametrize('command', [
2020-05-09 18:58:15 +01:00
# Command('gcloud comute instances list', misspelled_command),
2020-04-28 14:11:51 +00:00
Command('gcloud compute instance list', misspelled_subcommand)])
def test_match(command):
assert match(command)
2020-05-09 16:21:55 +01:00
2020-04-28 14:11:51 +00:00
def test_not_match():
assert not match(Command('aws dynamodb invalid', no_suggestions))
2020-05-09 16:21:55 +01:00
2020-05-09 18:58:15 +01:00
#@pytest.mark.parametrize('command, result', [
# (Command('gcloud comute', misspelled_command),
# ['gcloud compute instances list']),
# (Command('gcloud compute instance list', misspelled_subcommand),
# ['gcloud compute instances list'])])
#def test_get_new_command(command, result):
# assert get_new_command(command) == result