mirror of
https://github.com/dbcli/pgcli.git
synced 2024-09-11 13:56:36 +03:00
Add tests for auto-escaped tables/columns.
This commit is contained in:
parent
0921992306
commit
1e59d7a946
@ -4,7 +4,8 @@ from prompt_toolkit.document import Document
|
||||
|
||||
tables = {
|
||||
'users': ['id', 'email', 'first_name', 'last_name'],
|
||||
'orders': ['id', 'user_id', 'ordered_date', 'status']
|
||||
'orders': ['id', 'user_id', 'ordered_date', 'status'],
|
||||
'select': ['id', 'insert', 'ABC'],
|
||||
}
|
||||
|
||||
@pytest.fixture
|
||||
@ -205,3 +206,28 @@ def test_suggested_tables_after_on(completer, complete_event):
|
||||
assert set(result) == set([
|
||||
Completion(text='users', start_position=0),
|
||||
Completion(text='orders', start_position=0)])
|
||||
|
||||
def test_table_names_after_from(completer, complete_event):
|
||||
text = 'SELECT * FROM '
|
||||
position = len('SELECT * FROM ')
|
||||
result = set(completer.get_completions(
|
||||
Document(text=text, cursor_position=position),
|
||||
complete_event))
|
||||
assert set(result) == set([
|
||||
Completion(text='users', start_position=0),
|
||||
Completion(text='orders', start_position=0),
|
||||
Completion(text='"select"', start_position=0),
|
||||
])
|
||||
|
||||
def test_auto_escaped_col_names(completer, complete_event):
|
||||
text = 'SELECT from "select"'
|
||||
position = len('SELECT ')
|
||||
result = set(completer.get_completions(
|
||||
Document(text=text, cursor_position=position),
|
||||
complete_event))
|
||||
assert set(result) == set([
|
||||
Completion(text='*', start_position=0),
|
||||
Completion(text='id', start_position=0),
|
||||
Completion(text='"insert"', start_position=0),
|
||||
Completion(text='"ABC"', start_position=0), ] +
|
||||
list(map(Completion, completer.functions)))
|
||||
|
Loading…
Reference in New Issue
Block a user