mirror of
https://github.com/dbcli/pgcli.git
synced 2024-10-06 02:07:53 +03:00
Add a couple of tests suggested by @darikg
This commit is contained in:
parent
6cb8c38628
commit
b69404c215
@ -342,6 +342,22 @@ def test_suggested_join_conditions(completer, complete_event, text):
|
||||
Completion(text='u2', start_position=0, display_meta='table alias'),
|
||||
Completion(text='u2.userid = u.id', start_position=0, display_meta='fk join')])
|
||||
|
||||
@pytest.mark.parametrize('text', [
|
||||
'SELECT * FROM "Users" u JOIN u',
|
||||
'SELECT * FROM "Users" u JOIN uid',
|
||||
'SELECT * FROM "Users" u JOIN userid',
|
||||
'SELECT * FROM "Users" u JOIN id',
|
||||
])
|
||||
def test_suggested_joins_fuzzy(completer, complete_event, text):
|
||||
position = len(text)
|
||||
result = set(completer.get_completions(
|
||||
Document(text=text, cursor_position=position),
|
||||
complete_event))
|
||||
last_word = text.split()[-1]
|
||||
expected = Completion(text='users ON users.id = u.userid',
|
||||
start_position=-len(last_word), display_meta='join')
|
||||
assert expected in result
|
||||
|
||||
@pytest.mark.parametrize('text', [
|
||||
'SELECT * FROM users JOIN ',
|
||||
'''SELECT *
|
||||
|
@ -123,7 +123,7 @@ def test_suggest_tables_views_schemas_and_functions(expression):
|
||||
|
||||
@pytest.mark.parametrize('expression', [
|
||||
'SELECT * FROM foo JOIN bar on bar.barid = foo.barid JOIN ',
|
||||
'SELECT * FROM foo JOIN bar USING (barid) JOIN ',
|
||||
'SELECT * FROM foo JOIN bar USING (barid) JOIN '
|
||||
])
|
||||
def test_suggest_after_join_with_two_tables(expression):
|
||||
suggestions = suggest_type(expression, expression)
|
||||
@ -137,7 +137,8 @@ def test_suggest_after_join_with_two_tables(expression):
|
||||
|
||||
|
||||
@pytest.mark.parametrize('expression', [
|
||||
'SELECT * FROM foo JOIN '
|
||||
'SELECT * FROM foo JOIN ',
|
||||
'SELECT * FROM foo JOIN bar'
|
||||
])
|
||||
def test_suggest_after_join_with_one_table(expression):
|
||||
suggestions = suggest_type(expression, expression)
|
||||
|
Loading…
Reference in New Issue
Block a user