diff options
author | Sean Enck <enckse@users.noreply.github.com> | 2023-01-28 02:20:29 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-28 00:20:29 -0700 |
commit | 0af4899605af26dd8ea7fe79acff6ab99f6532b2 (patch) | |
tree | d6710b9f126fc62307206645f12b988be8282319 /test/fixers | |
parent | 65088b59b75ef6d6c1429ee5a5da2c6a15257fdf (diff) | |
download | ale-0af4899605af26dd8ea7fe79acff6ab99f6532b2.zip |
Add `gopls format` as a Go fixer
Diffstat (limited to 'test/fixers')
-rw-r--r-- | test/fixers/test_gopls_fixer_callback.vader | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/test/fixers/test_gopls_fixer_callback.vader b/test/fixers/test_gopls_fixer_callback.vader new file mode 100644 index 00000000..218a356a --- /dev/null +++ b/test/fixers/test_gopls_fixer_callback.vader @@ -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('')) |