-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add option to use function for generating connection string
Add ability to use function for generating a connection string through `g:dbs` variable. Closes #251 and #204
- Loading branch information
1 parent
696e1ed
commit dc6975d
Showing
5 changed files
with
128 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
test/test-initialization-with-dbs-array-function-variable.vim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
let s:suite = themis#suite('Initialization with g:dbs variable as functions in a dictionary') | ||
let s:expect = themis#helper('expect') | ||
|
||
function! s:db_conn() abort | ||
return 'sqlite:tests/dadbod_ui_test.db' | ||
endfunction | ||
|
||
function! s:suite.before() abort | ||
call SetupTestDbs() | ||
let g:dbs = [ | ||
\ { 'name': 'dadbod_gdb_test_function', 'url': function('s:db_conn') }, | ||
\ { 'name': 'dadbod_gdb_test_str', 'url': 'sqlite:test/dadbod_ui_test' }, | ||
\ ] | ||
endfunction | ||
|
||
function! s:suite.after() abort | ||
call Cleanup() | ||
endfunction | ||
|
||
function! s:suite.should_read_global_dbs_variable() abort | ||
:DBUI | ||
call s:expect(&filetype).to_equal('dbui') | ||
call s:expect(getline(1)).to_equal(printf('%s %s', g:db_ui_icons.collapsed.db, 'dadbod_gdb_test_function')) | ||
call s:expect(getline(2)).to_equal(printf('%s %s', g:db_ui_icons.collapsed.db, 'dadbod_gdb_test_str')) | ||
norm o | ||
call s:expect(getline(1, '$')).to_equal([ | ||
\ '▾ dadbod_gdb_test_function '.g:db_ui_icons.connection_ok, | ||
\ ' + New query', | ||
\ ' ▸ Saved queries (0)', | ||
\ ' ▸ Tables (2)', | ||
\ '▸ dadbod_gdb_test_str', | ||
\ ]) | ||
endfunction |
33 changes: 33 additions & 0 deletions
33
test/test-initialization-with-dbs-dictionary-function-variable.vim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
let s:suite = themis#suite('Initialization with g:dbs variable as functions in a dictionary') | ||
let s:expect = themis#helper('expect') | ||
|
||
function! s:db_conn() abort | ||
return 'sqlite:tests/dadbod_ui_test.db' | ||
endfunction | ||
|
||
function! s:suite.before() abort | ||
call SetupTestDbs() | ||
let g:dbs = { | ||
\ 'dadbod_gdb_test_fn': function('s:db_conn'), | ||
\ 'dadbod_gdb_test_string': 'sqlite:test/dadbod_ui_test', | ||
\ } | ||
endfunction | ||
|
||
function! s:suite.after() abort | ||
call Cleanup() | ||
endfunction | ||
|
||
function! s:suite.should_read_global_dbs_variable() abort | ||
:DBUI | ||
call s:expect(&filetype).to_equal('dbui') | ||
call s:expect(getline(1)).to_equal(printf('%s %s', g:db_ui_icons.collapsed.db, 'dadbod_gdb_test_string')) | ||
call s:expect(getline(2)).to_equal(printf('%s %s', g:db_ui_icons.collapsed.db, 'dadbod_gdb_test_fn')) | ||
norm jo | ||
call s:expect(getline(1, '$')).to_equal([ | ||
\ '▸ dadbod_gdb_test_string', | ||
\ '▾ dadbod_gdb_test_fn '.g:db_ui_icons.connection_ok, | ||
\ ' + New query', | ||
\ ' ▸ Saved queries (0)', | ||
\ ' ▸ Tables (2)', | ||
\ ]) | ||
endfunction |