diff options
author | Martin Tournoij <martin@arp242.net> | 2018-09-19 19:33:23 +0100 |
---|---|---|
committer | w0rp <w0rp@users.noreply.github.com> | 2018-09-19 19:33:23 +0100 |
commit | e82bcdb8a6dc888130c03bc80cba492051c5ffbf (patch) | |
tree | 7ac138a0990261e3ff70f518a5a01dc311a31230 /test | |
parent | a6c6e24d61c3d67f46cb9e3d5a8d4c8475b8a8c6 (diff) | |
download | ale-e82bcdb8a6dc888130c03bc80cba492051c5ffbf.zip |
Add fixer for Go modules (#1873)
* Add fixer for Go modules
Diffstat (limited to 'test')
-rw-r--r-- | test/command_callback/test_gobuild_command_callback.vader | 12 | ||||
-rw-r--r-- | test/command_callback/test_govet_command_callback.vader | 11 | ||||
-rw-r--r-- | test/fixers/test_gomod_fixer_callback.vader | 24 | ||||
-rw-r--r-- | test/go_files/go.mod | 1 |
4 files changed, 46 insertions, 2 deletions
diff --git a/test/command_callback/test_gobuild_command_callback.vader b/test/command_callback/test_gobuild_command_callback.vader index f9673213..8acbec56 100644 --- a/test/command_callback/test_gobuild_command_callback.vader +++ b/test/command_callback/test_gobuild_command_callback.vader @@ -1,9 +1,12 @@ Before: + Save g:ale_go_go_executable + call ale#assert#SetUpLinterTest('go', 'gobuild') WithChainResults ['/foo/bar', '/foo/baz'] After: + Restore call ale#assert#TearDownLinterTest() Execute(The default commands should be correct): @@ -17,3 +20,12 @@ Execute(Extra options should be supported): AssertLinter 'go', \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' \ . 'go test --foo-bar -c -o /dev/null ./' + + let g:ale_go_gobuild_options = '' + +Execute(The executable should be configurable): + let g:ale_go_go_executable = 'foobar' + + AssertLinter 'foobar', + \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' + \ . 'foobar test -c -o /dev/null ./' diff --git a/test/command_callback/test_govet_command_callback.vader b/test/command_callback/test_govet_command_callback.vader index 3718e0a7..ab93a5cb 100644 --- a/test/command_callback/test_govet_command_callback.vader +++ b/test/command_callback/test_govet_command_callback.vader @@ -1,12 +1,19 @@ Before: + Save g:ale_go_go_executable + Save g:ale_go_govet_options call ale#assert#SetUpLinterTest('go', 'govet') After: + Restore call ale#assert#TearDownLinterTest() Execute(The default command should be correct): - AssertLinter 'go', 'cd ' . ale#Escape(expand('%:p:h')) . ' && go vet .' + AssertLinter 'go', 'cd ' . ale#Escape(expand('%:p:h')) . ' && go vet .' Execute(Extra options should be supported): let g:ale_go_govet_options = '--foo-bar' - AssertLinter 'go', 'cd ' . ale#Escape(expand('%:p:h')) . ' && go vet . --foo-bar' + AssertLinter 'go', 'cd ' . ale#Escape(expand('%:p:h')) . ' && go vet --foo-bar .' + +Execute(The executable should be configurable): + let g:ale_go_go_executable = 'foobar' + AssertLinter 'foobar', 'cd ' . ale#Escape(expand('%:p:h')) . ' && foobar vet .' diff --git a/test/fixers/test_gomod_fixer_callback.vader b/test/fixers/test_gomod_fixer_callback.vader new file mode 100644 index 00000000..a378e961 --- /dev/null +++ b/test/fixers/test_gomod_fixer_callback.vader @@ -0,0 +1,24 @@ +Before: + Save g:ale_go_go_executable + + " Use an invalid global executable, so we don't match it. + let g:ale_go_go_executable = 'xxxinvalid' + call ale#test#SetDirectory('/testplugin/test/fixers') + +After: + Restore + + call ale#test#RestoreDirectory() + +Execute(The gomod callback should return the correct default values): + call ale#test#SetFilename('../go_files/go.mod') + setl ft=gomod + + AssertEqual + \ { + \ 'read_temporary_file': 1, + \ 'command': ale#Escape('xxxinvalid') + \ . ' mod edit -fmt' + \ . ' %t', + \ }, + \ ale#fixers#gomod#Fix(bufnr('')) diff --git a/test/go_files/go.mod b/test/go_files/go.mod new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/test/go_files/go.mod @@ -0,0 +1 @@ + |