]> git.madduck.net Git - etc/vim.git/blob - .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:

Do not set EDITOR/VISUAL for shell
[etc/vim.git] / .vim / bundle / ale / test / handler / test_ansible_lint_handler.vader
1 Before:
2   Save b:ale_warn_about_trailing_whitespace
3
4   runtime ale_linters/ansible/ansible_lint.vim
5   call ale#test#SetFilename('test_playbook.yml')
6
7   let b:ale_warn_about_trailing_whitespace = 1
8
9 After:
10   Restore
11
12   call ale#linter#Reset()
13
14 Execute(The ansible-lint handler for version group <5 should handle basic errors):
15   AssertEqual
16   \ [
17   \   {
18   \    'lnum': 35,
19   \    'col': 0,
20   \    'type': 'E',
21   \    'text': 'Trailing whitespace',
22   \    'code': 'EANSIBLE0002',
23   \   },
24   \ ],
25   \ ale_linters#ansible#ansible_lint#Handle(bufnr(''), [4, 1, 2], [
26   \ fnamemodify(tempname(), ':h') . '/test_playbook.yml:35: [EANSIBLE0002] Trailing whitespace',
27   \ ])
28
29 Execute(The ansible-lint handler for version group <5 should suppress trailing whitespace output when the option is used):
30   let b:ale_warn_about_trailing_whitespace = 0
31
32   AssertEqual
33   \ [
34   \ ],
35   \ ale_linters#ansible#ansible_lint#Handle(bufnr(''), [4, 1, 2], [
36   \ fnamemodify(tempname(), ':h') . '/test_playbook.yml:35: [EANSIBLE0002] Trailing whitespace',
37   \ ])
38
39
40 Execute(The ansible-lint handler for version group >=5 should handle basic errors):
41   AssertEqual
42   \ [
43   \   {
44   \    'lnum': 35,
45   \    'col': 0,
46   \    'type': 'E',
47   \    'text': 'File permissions unset or incorrect',
48   \    'code': 'risky-file-permissions',
49   \   },
50   \ ],
51   \ ale_linters#ansible#ansible_lint#Handle(bufnr(''), [5, 1, 2], [
52   \ fnamemodify(tempname(), ':h') . '/test_playbook.yml:35: [risky-file-permissions] [VERY_HIGH] File permissions unset or incorrect',
53   \ ])
54
55 Before:
56   runtime ale_linters/ansible/ansible_lint.vim
57   call ale#test#SetFilename('test playbook.yml')
58
59 After:
60   call ale#linter#Reset()
61
62 Execute (The ansible-lint handler for version group <5 should handle names with spaces):
63   AssertEqual
64   \ [
65   \   {
66   \     'lnum': 6,
67   \     'col': 6,
68   \     'type': 'E',
69   \     'text': 'indentation is not a multiple of four',
70   \     'code': 'E111',
71   \   },
72   \ ],
73   \ ale_linters#ansible#ansible_lint#Handle(bufnr(''), [4, 1, 2], [
74   \ fnamemodify(tempname(), ':h') . '/test playbook.yml:6:6: E111 indentation is not a multiple of four',
75   \ ])
76
77 Execute (The ansible-lint handler for version group >=5 should handle names with spaces):
78   AssertEqual
79   \ [
80   \   {
81   \     'lnum': 3,
82   \     'col': 148,
83   \     'type': 'E',
84   \     'text': "'var' is not a valid attribute for a Play",
85   \     'code': 'syntax-check',
86   \   },
87   \ ],
88   \ ale_linters#ansible#ansible_lint#Handle(bufnr(''), [5, 1, 2], [
89   \ fnamemodify(tempname(), ':h') . "/test playbook.yml:3:148: [syntax-check] [VERY_HIGH] 'var' is not a valid attribute for a Play",
90   \ ])
91
92 Execute (The ansible-lint handler should work with issues with positions and lines members):
93   AssertEqual
94   \ [
95   \   {
96   \     'lnum': 6,
97   \     'col': 7,
98   \     'code': 'major',
99   \     'type': 'W',
100   \     'text': "syntax-check[specific]",
101   \     'detail': 'fakedesc',
102   \   },
103   \   {
104   \     'lnum': 6,
105   \     'col': 0,
106   \     'code': 'major',
107   \     'type': 'W',
108   \     'text': 'fqcn[action-core]',
109   \     'detail': 'fakedesc2'
110   \   }
111   \ ],
112   \ ale_linters#ansible#ansible_lint#Handle(bufnr(''), [6, 11, 0], [
113   \  '[',
114   \  '  {',
115   \  '    "type": "issue",',
116   \  '    "check_name": "syntax-check[specific]",',
117   \  '    "categories": [',
118   \  '      "core",',
119   \  '      "unskippable"',
120   \  '    ],',
121   \  '    "url": "https://ansible-lint.readthedocs.io/rules/syntax-check/",',
122   \  '    "severity": "major",',
123   \  '    "description": "fakedesc",',
124   \  '    "fingerprint": "4",',
125   \  '    "location": {',
126   \  '      "path": "test playbook.yml",',
127   \  '      "positions": {',
128   \  '        "begin": {',
129   \  '          "line": 6,',
130   \  '          "column": 7',
131   \  '        }',
132   \  '      }',
133   \  '    }',
134   \  '  },',
135   \  '  {',
136   \  '    "type": "issue",',
137   \  '    "check_name": "fqcn[action-core]",',
138   \  '    "categories": [',
139   \  '      "formatting"',
140   \  '    ],',
141   \  '    "url": "https://ansible-lint.readthedocs.io/rules/fqcn/",',
142   \  '    "severity": "major",',
143   \  '    "description": "fakedesc2",',
144   \  '    "fingerprint": "f",',
145   \  '    "location": {',
146   \  '      "path": "test playbook.yml",',
147   \  '      "lines": {',
148   \  '        "begin": 6',
149   \  '      }',
150   \  '    },',
151   \  '    "content": {',
152   \  '      "body": "Use `ansible.builtin.command` or `ansible.legacy.command` instead."',
153   \  '    }',
154   \  '  }',
155   \  ']'
156   \ ])
157
158 Execute (The ansible-lint handler should ignore errors from other files):
159   AssertEqual
160   \ [
161   \ ],
162   \ ale_linters#ansible#ansible_lint#Handle(bufnr(''), [5, 1, 2], [
163   \   '/foo/bar/roles/test_playbook.yml:6: [command-instead-of-module] [VERY_LOW] curl used in place of get_url or uri module',
164   \ ])
165
166 Execute (The ansible-lint handler should work with empty input):
167   AssertEqual
168   \ [
169   \ ],
170   \ ale_linters#ansible#ansible_lint#Handle(bufnr(''), [6, 0, 0], [])