From 7e9d4fbfc820ae4198b07b204295fc3acd391209 Mon Sep 17 00:00:00 2001 From: Gonzalo Quero Date: Mon, 23 Nov 2020 10:21:09 +0000 Subject: [PATCH] refactor: Move test to the right file --- ale_linters/elixir/credo.vim | 6 ++-- test/command_callback/test_elixir_credo.vader | 7 ++++ test/test_elixir_credo.vader | 35 ------------------- 3 files changed, 10 insertions(+), 38 deletions(-) delete mode 100644 test/test_elixir_credo.vader diff --git a/ale_linters/elixir/credo.vim b/ale_linters/elixir/credo.vim index 15ebefb5..892d47b9 100644 --- a/ale_linters/elixir/credo.vim +++ b/ale_linters/elixir/credo.vim @@ -48,11 +48,11 @@ endfunction function! ale_linters#elixir#credo#GetConfigFile() abort let l:config_file = get(g:, 'ale_elixir_credo_config_file', '') - if len(l:config_file) == 0 + if empty(l:config_file) return '' - else - return ' --config-file ' . l:config_file endif + + return ' --config-file ' . l:config_file endfunction function! ale_linters#elixir#credo#GetCommand(buffer) abort diff --git a/test/command_callback/test_elixir_credo.vader b/test/command_callback/test_elixir_credo.vader index 3eb88846..b14444c6 100644 --- a/test/command_callback/test_elixir_credo.vader +++ b/test/command_callback/test_elixir_credo.vader @@ -38,3 +38,10 @@ Execute(Builds credo command with suggest mode when set to 0): AssertLinter 'mix', \ ale#path#CdString(ale#path#Simplify(g:dir . '/elixir_paths/mix_project')) \ . 'mix help credo && mix credo suggest --format=flycheck --read-from-stdin %s' + +Execute(Builds credo command with a custom config file): + let g:ale_elixir_credo_config_file = '/home/user/custom_credo.exs' + + AssertLinter 'mix', + \ ale#path#CdString(ale#path#Simplify(g:dir . '/elixir_paths/mix_project')) + \ . 'mix help credo && mix credo suggest --config-file /home/user/custom_credo.exs --format=flycheck --read-from-stdin %s' diff --git a/test/test_elixir_credo.vader b/test/test_elixir_credo.vader deleted file mode 100644 index 78d3e0a6..00000000 --- a/test/test_elixir_credo.vader +++ /dev/null @@ -1,35 +0,0 @@ -Before: - call ale#test#SetDirectory('/testplugin/test') - - runtime ale_linters/elixir/credo.vim - let g:test_command_start = ale#path#CdString('.') . 'mix help credo && ' - -After: - call ale#test#RestoreDirectory() - call ale#linter#Reset() - let g:ale_elixir_credo_strict = 0 - let g:ale_elixir_credo_config_file = '' - let g:test_command_start = '' - -Execute(credo runs the right command): - call ale#test#SetFilename('elixir-test-files/testfile.ex') - - AssertEqual - \ ale_linters#elixir#credo#GetCommand(bufnr('')), - \ g:test_command_start . 'mix credo suggest --format=flycheck --read-from-stdin %s' - -Execute(credo runs the right command with the strict flag): - let g:ale_elixir_credo_strict = 1 - call ale#test#SetFilename('elixir-test-files/testfile.ex') - - AssertEqual - \ ale_linters#elixir#credo#GetCommand(bufnr('')), - \ g:test_command_start . 'mix credo --strict --format=flycheck --read-from-stdin %s' - -Execute(credo runs the right command with a custom config file): - let g:ale_elixir_credo_config_file = '/home/user/custom_credo.exs' - call ale#test#SetFilename('elixir-test-files/testfile.ex') - - AssertEqual - \ ale_linters#elixir#credo#GetCommand(bufnr('')), - \ g:test_command_start . 'mix credo suggest --config-file /home/user/custom_credo.exs --format=flycheck --read-from-stdin %s'