2017-11-14 17:37:22 +00:00
|
|
|
Before:
|
|
|
|
Save g:ale_go_goimports_executable
|
|
|
|
Save g:ale_go_goimports_options
|
2019-08-02 08:09:10 +00:00
|
|
|
Save g:ale_go_go111module
|
2017-11-14 17:37:22 +00:00
|
|
|
|
|
|
|
" Use an invalid global executable, so we don't match it.
|
|
|
|
let g:ale_go_goimports_executable = 'xxxinvalid'
|
|
|
|
let g:ale_go_goimports_options = ''
|
|
|
|
|
|
|
|
call ale#test#SetDirectory('/testplugin/test/fixers')
|
2021-03-20 22:11:22 +00:00
|
|
|
call ale#test#SetFilename('../test-files/go/testfile.go')
|
2017-11-14 17:37:22 +00:00
|
|
|
|
|
|
|
After:
|
|
|
|
Restore
|
|
|
|
|
2019-08-02 08:09:10 +00:00
|
|
|
unlet! b:ale_go_go111module
|
|
|
|
|
2017-11-14 17:37:22 +00:00
|
|
|
call ale#test#RestoreDirectory()
|
|
|
|
|
2017-11-14 17:46:40 +00:00
|
|
|
Execute(The goimports callback should return 0 when the executable isn't executable):
|
2017-11-14 17:37:22 +00:00
|
|
|
AssertEqual
|
|
|
|
\ 0,
|
|
|
|
\ ale#fixers#goimports#Fix(bufnr(''))
|
|
|
|
|
2017-11-14 17:46:40 +00:00
|
|
|
Execute(The goimports callback should the command when the executable test passes):
|
|
|
|
let g:ale_go_goimports_executable = has('win32') ? 'cmd' : 'echo'
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ {
|
|
|
|
\ 'read_temporary_file': 1,
|
2017-12-06 13:04:31 +00:00
|
|
|
\ 'command': ale#Escape(g:ale_go_goimports_executable) . ' -l -w -srcdir %s %t'
|
2017-11-14 17:46:40 +00:00
|
|
|
\ },
|
|
|
|
\ ale#fixers#goimports#Fix(bufnr(''))
|
|
|
|
|
|
|
|
Execute(The goimports callback should include extra options):
|
|
|
|
let g:ale_go_goimports_executable = has('win32') ? 'cmd' : 'echo'
|
|
|
|
let g:ale_go_goimports_options = '--xxx'
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ {
|
|
|
|
\ 'read_temporary_file': 1,
|
2017-12-06 13:04:31 +00:00
|
|
|
\ 'command': ale#Escape(g:ale_go_goimports_executable) . ' -l -w -srcdir %s --xxx %t'
|
2017-11-14 17:46:40 +00:00
|
|
|
\ },
|
|
|
|
\ ale#fixers#goimports#Fix(bufnr(''))
|
2019-04-11 02:25:06 +00:00
|
|
|
|
|
|
|
Execute(The goimports callback should support Go environment variables):
|
|
|
|
let g:ale_go_goimports_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_goimports_executable)
|
|
|
|
\ . ' -l -w -srcdir %s %t'
|
|
|
|
\ },
|
|
|
|
\ ale#fixers#goimports#Fix(bufnr(''))
|