summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/command_callback/test_ansible_lint_command_callback.vader9
-rw-r--r--test/handler/test_ansible_lint_handler.vader63
2 files changed, 57 insertions, 15 deletions
diff --git a/test/command_callback/test_ansible_lint_command_callback.vader b/test/command_callback/test_ansible_lint_command_callback.vader
index ddc6c6c8..a3fbde23 100644
--- a/test/command_callback/test_ansible_lint_command_callback.vader
+++ b/test/command_callback/test_ansible_lint_command_callback.vader
@@ -7,11 +7,16 @@ After:
unlet! b:executable
call ale#assert#TearDownLinterTest()
-Execute(The ansible_lint command callback should return default string):
+Execute(The ansible_lint version <5.0.0 command callback should return default string):
+ GivenCommandOutput ['v4.1.2']
AssertLinter 'ansible-lint', ale#Escape('ansible-lint') . ' -p %t'
+Execute(The ansible_lint version >=5.0.0 command callback should return default string):
+ GivenCommandOutput ['v5.1.2']
+ AssertLinter 'ansible-lint', ale#Escape('ansible-lint') . ' --parseable-severity -x yaml'
+
Execute(The ansible_lint executable should be configurable):
let g:ale_ansible_ansible_lint_executable = '~/.local/bin/ansible-lint'
-
+ GivenCommandOutput ['v4.1.2']
AssertLinter '~/.local/bin/ansible-lint',
\ ale#Escape('~/.local/bin/ansible-lint') . ' -p %t'
diff --git a/test/handler/test_ansible_lint_handler.vader b/test/handler/test_ansible_lint_handler.vader
index 796277e6..28dbba30 100644
--- a/test/handler/test_ansible_lint_handler.vader
+++ b/test/handler/test_ansible_lint_handler.vader
@@ -1,15 +1,14 @@
Before:
runtime ale_linters/ansible/ansible_lint.vim
- call ale#test#SetFilename('main.yml')
+ call ale#test#SetFilename('test_playbook.yml')
let b:ale_warn_about_trailing_whitespace = 1
After:
unlet! b:ale_warn_about_trailing_whitespace
-
call ale#linter#Reset()
-Execute(The ansible-lint handler should handle basic errors):
+Execute(The ansible-lint handler for version group <5 should handle basic errors):
AssertEqual
\ [
\ {
@@ -20,21 +19,44 @@ Execute(The ansible-lint handler should handle basic errors):
\ 'code': 'EANSIBLE0002',
\ },
\ ],
- \ ale_linters#ansible#ansible_lint#Handle(bufnr(''), [
- \ fnamemodify(tempname(), ':h') . '/main.yml:35: [EANSIBLE0002] Trailing whitespace',
+ \ ale_linters#ansible#ansible_lint#Handle(bufnr(''), [4, 1, 2], [
+ \ fnamemodify(tempname(), ':h') . '/test_playbook.yml:35: [EANSIBLE0002] Trailing whitespace',
\ ])
-Execute(The ansible-lint handler should supress trailing whitespace output when the option is used):
+Execute(The ansible-lint handler for version group <5 should supress trailing whitespace output when the option is used):
let b:ale_warn_about_trailing_whitespace = 0
AssertEqual
\ [
\ ],
- \ ale_linters#ansible#ansible_lint#Handle(bufnr(''), [
- \ fnamemodify(tempname(), ':h') . '/main.yml:35: [EANSIBLE0002] Trailing whitespace',
+ \ ale_linters#ansible#ansible_lint#Handle(bufnr(''), [4, 1, 2], [
+ \ fnamemodify(tempname(), ':h') . '/test_playbook.yml:35: [EANSIBLE0002] Trailing whitespace',
\ ])
-Execute (The ansible-lint handler should handle names with spaces):
+
+Execute(The ansible-lint handler for version group >=5 should handle basic errors):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 35,
+ \ 'col': 0,
+ \ 'type': 'E',
+ \ 'text': 'File permissions unset or incorrect',
+ \ 'code': 'risky-file-permissions',
+ \ },
+ \ ],
+ \ ale_linters#ansible#ansible_lint#Handle(bufnr(''), [5, 1, 2], [
+ \ fnamemodify(tempname(), ':h') . '/test_playbook.yml:35: [risky-file-permissions] [VERY_HIGH] File permissions unset or incorrect',
+ \ ])
+
+Before:
+ runtime ale_linters/ansible/ansible_lint.vim
+ call ale#test#SetFilename('test playbook.yml')
+
+After:
+ call ale#linter#Reset()
+
+Execute (The ansible-lint handler for version group <5 should handle names with spaces):
AssertEqual
\ [
\ {
@@ -45,14 +67,29 @@ Execute (The ansible-lint handler should handle names with spaces):
\ 'code': 'E111',
\ },
\ ],
- \ ale_linters#ansible#ansible_lint#Handle(bufnr(''), [
- \ fnamemodify(tempname(), ':h') . '/main.yml:6:6: E111 indentation is not a multiple of four',
+ \ ale_linters#ansible#ansible_lint#Handle(bufnr(''), [4, 1, 2], [
+ \ fnamemodify(tempname(), ':h') . '/test playbook.yml:6:6: E111 indentation is not a multiple of four',
+ \ ])
+
+Execute (The ansible-lint handler for version group >=5 should handle names with spaces):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 3,
+ \ 'col': 148,
+ \ 'type': 'E',
+ \ 'text': "'var' is not a valid attribute for a Play",
+ \ 'code': 'syntax-check',
+ \ },
+ \ ],
+ \ ale_linters#ansible#ansible_lint#Handle(bufnr(''), [5, 1, 2], [
+ \ fnamemodify(tempname(), ':h') . "/test playbook.yml:3:148: [syntax-check] [VERY_HIGH] 'var' is not a valid attribute for a Play",
\ ])
Execute (The ansible-lint handler should ignore errors from other files):
AssertEqual
\ [
\ ],
- \ ale_linters#ansible#ansible_lint#Handle(bufnr(''), [
- \ '/foo/bar/roles/main.yml:6:6: E111 indentation is not a multiple of four',
+ \ ale_linters#ansible#ansible_lint#Handle(bufnr(''), [5, 1, 2], [
+ \ '/foo/bar/roles/test_playbook.yml:6: [command-instead-of-module] [VERY_LOW] curl used in place of get_url or uri module',
\ ])