]> git.madduck.net Git - etc/vim.git/blobdiff - .vim/bundle/ale/test/handler/test_ansible_lint_handler.vader

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit '76265755a1add77121c8f9dabb3e9bb70fe9a972' as '.vim/bundle/ale'
[etc/vim.git] / .vim / bundle / ale / test / handler / test_ansible_lint_handler.vader
diff --git a/.vim/bundle/ale/test/handler/test_ansible_lint_handler.vader b/.vim/bundle/ale/test/handler/test_ansible_lint_handler.vader
new file mode 100644 (file)
index 0000000..e0c67ab
--- /dev/null
@@ -0,0 +1,170 @@
+Before:
+  Save b:ale_warn_about_trailing_whitespace
+
+  runtime ale_linters/ansible/ansible_lint.vim
+  call ale#test#SetFilename('test_playbook.yml')
+
+  let b:ale_warn_about_trailing_whitespace = 1
+
+After:
+  Restore
+
+  call ale#linter#Reset()
+
+Execute(The ansible-lint handler for version group <5 should handle basic errors):
+  AssertEqual
+  \ [
+  \   {
+  \    'lnum': 35,
+  \    'col': 0,
+  \    'type': 'E',
+  \    'text': 'Trailing whitespace',
+  \    'code': 'EANSIBLE0002',
+  \   },
+  \ ],
+  \ 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 for version group <5 should suppress trailing whitespace output when the option is used):
+  let b:ale_warn_about_trailing_whitespace = 0
+
+  AssertEqual
+  \ [
+  \ ],
+  \ 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 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
+  \ [
+  \   {
+  \     'lnum': 6,
+  \     'col': 6,
+  \     'type': 'E',
+  \     'text': 'indentation is not a multiple of four',
+  \     'code': 'E111',
+  \   },
+  \ ],
+  \ 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 work with issues with positions and lines members):
+  AssertEqual
+  \ [
+  \   {
+  \     'lnum': 6,
+  \     'col': 7,
+  \     'code': 'major',
+  \     'type': 'W',
+  \     'text': "syntax-check[specific]",
+  \     'detail': 'fakedesc',
+  \   },
+  \   {
+  \     'lnum': 6,
+  \     'col': 0,
+  \     'code': 'major',
+  \     'type': 'W',
+  \     'text': 'fqcn[action-core]',
+  \     'detail': 'fakedesc2'
+  \   }
+  \ ],
+  \ ale_linters#ansible#ansible_lint#Handle(bufnr(''), [6, 11, 0], [
+  \  '[',
+  \  '  {',
+  \  '    "type": "issue",',
+  \  '    "check_name": "syntax-check[specific]",',
+  \  '    "categories": [',
+  \  '      "core",',
+  \  '      "unskippable"',
+  \  '    ],',
+  \  '    "url": "https://ansible-lint.readthedocs.io/rules/syntax-check/",',
+  \  '    "severity": "major",',
+  \  '    "description": "fakedesc",',
+  \  '    "fingerprint": "4",',
+  \  '    "location": {',
+  \  '      "path": "test playbook.yml",',
+  \  '      "positions": {',
+  \  '        "begin": {',
+  \  '          "line": 6,',
+  \  '          "column": 7',
+  \  '        }',
+  \  '      }',
+  \  '    }',
+  \  '  },',
+  \  '  {',
+  \  '    "type": "issue",',
+  \  '    "check_name": "fqcn[action-core]",',
+  \  '    "categories": [',
+  \  '      "formatting"',
+  \  '    ],',
+  \  '    "url": "https://ansible-lint.readthedocs.io/rules/fqcn/",',
+  \  '    "severity": "major",',
+  \  '    "description": "fakedesc2",',
+  \  '    "fingerprint": "f",',
+  \  '    "location": {',
+  \  '      "path": "test playbook.yml",',
+  \  '      "lines": {',
+  \  '        "begin": 6',
+  \  '      }',
+  \  '    },',
+  \  '    "content": {',
+  \  '      "body": "Use `ansible.builtin.command` or `ansible.legacy.command` instead."',
+  \  '    }',
+  \  '  }',
+  \  ']'
+  \ ])
+
+Execute (The ansible-lint handler should ignore errors from other files):
+  AssertEqual
+  \ [
+  \ ],
+  \ 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',
+  \ ])
+
+Execute (The ansible-lint handler should work with empty input):
+  AssertEqual
+  \ [
+  \ ],
+  \ ale_linters#ansible#ansible_lint#Handle(bufnr(''), [6, 0, 0], [])