mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-06 12:44:23 +08:00
Add gopls format as a Go fixer
This commit is contained in:
57
test/fixers/test_gopls_fixer_callback.vader
Normal file
57
test/fixers/test_gopls_fixer_callback.vader
Normal file
@@ -0,0 +1,57 @@
|
||||
Before:
|
||||
Save g:ale_go_gopls_fix_executable
|
||||
Save g:ale_go_gopls_fix_options
|
||||
Save g:ale_go_go111module
|
||||
|
||||
" Use an invalid global executable, so we don't match it.
|
||||
let g:ale_go_gopls_fix_executable = 'xxxinvalid'
|
||||
let g:ale_go_gopls_fix_options = ''
|
||||
|
||||
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||
call ale#test#SetFilename('../test-files/go/testfile.go')
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
unlet! b:ale_go_go111module
|
||||
|
||||
call ale#test#RestoreDirectory()
|
||||
|
||||
Execute(The gopls callback should return 0 when the executable isn't executable):
|
||||
AssertEqual
|
||||
\ 0,
|
||||
\ ale#fixers#gopls#Fix(bufnr(''))
|
||||
|
||||
Execute(The gopls callback should the command when the executable test passes):
|
||||
let g:ale_go_gopls_fix_executable = has('win32') ? 'cmd' : 'echo'
|
||||
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command': ale#Escape(g:ale_go_gopls_fix_executable) . ' format -l -w %t'
|
||||
\ },
|
||||
\ ale#fixers#gopls#Fix(bufnr(''))
|
||||
|
||||
Execute(The gopls callback should include extra options):
|
||||
let g:ale_go_gopls_fix_executable = has('win32') ? 'cmd' : 'echo'
|
||||
let g:ale_go_gopls_fix_options = '--xxx'
|
||||
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command': ale#Escape(g:ale_go_gopls_fix_executable) . ' format --xxx -l -w %t'
|
||||
\ },
|
||||
\ ale#fixers#gopls#Fix(bufnr(''))
|
||||
|
||||
Execute(The gopls callback should support Go environment variables):
|
||||
let g:ale_go_gopls_fix_executable = has('win32') ? 'cmd' : 'echo'
|
||||
let g:ale_go_go111module = 'on'
|
||||
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command': ale#Env('GO111MODULE', 'on')
|
||||
\ . ale#Escape(g:ale_go_gopls_fix_executable)
|
||||
\ . ' format -l -w %t'
|
||||
\ },
|
||||
\ ale#fixers#gopls#Fix(bufnr(''))
|
||||
Reference in New Issue
Block a user