/ test / handler / test_gitlint_handler.vader
test_gitlint_handler.vader
 1  Before:
 2    Save g:ale_warn_about_trailing_whitespace
 3  
 4    let g:ale_warn_about_trailing_whitespace = 1
 5  
 6    runtime ale_linters/gitcommit/gitlint.vim
 7  
 8  After:
 9    Restore
10  
11    unlet! b:ale_warn_about_trailing_whitespace
12  
13    call ale#linter#Reset()
14  
15  Execute(The gitlint handler should handle basic warnings and syntax errors):
16    AssertEqual
17    \ [
18    \   {
19    \     'lnum': 1,
20    \     'type': 'E',
21    \     'text': 'Body message is missing',
22    \     'code': 'B6',
23    \   },
24    \   {
25    \     'lnum': 2,
26    \     'type': 'E',
27    \     'text': 'Second line is not empty: "to send to upstream"',
28    \     'code': 'B4',
29    \   },
30    \   {
31    \     'lnum': 3,
32    \     'type': 'E',
33    \     'text': 'Body message is too short (19<20): "to send to upstream"',
34    \     'code': 'B5',
35    \   },
36    \   {
37    \     'lnum': 8,
38    \     'type': 'E',
39    \     'text': 'Title exceeds max length (92>72): "some very long commit subject line where the author can''t wait to explain what he just fixed"',
40    \     'code': 'T1',
41    \   },
42    \ ],
43    \ ale_linters#gitcommit#gitlint#Handle(1, [
44    \   '1: B6 Body message is missing',
45    \   '2: B4 Second line is not empty: "to send to upstream"',
46    \   '3: B5 Body message is too short (19<20): "to send to upstream"',
47    \   '8: T1 Title exceeds max length (92>72): "some very long commit subject line where the author can''t wait to explain what he just fixed"'
48    \ ])
49  
50  Execute(Disabling trailing whitespace warnings should work):
51    AssertEqual
52    \ [
53    \   {
54    \     'lnum': 8,
55    \     'type': 'E',
56    \     'text': 'Trailing whitespace',
57    \     'code': 'T2',
58    \   },
59    \ ],
60    \ ale_linters#gitcommit#gitlint#Handle(bufnr(''), [
61    \   '8: T2 Trailing whitespace',
62    \])
63  
64    AssertEqual
65    \ [
66    \   {
67    \     'lnum': 8,
68    \     'type': 'E',
69    \     'text': 'Trailing whitespace',
70    \     'code': 'B2',
71    \   },
72    \ ],
73    \ ale_linters#gitcommit#gitlint#Handle(bufnr(''), [
74    \   '8: B2 Trailing whitespace',
75    \])
76  
77    let b:ale_warn_about_trailing_whitespace = 0
78  
79    AssertEqual
80    \ [],
81    \ ale_linters#gitcommit#gitlint#Handle(bufnr(''), [
82    \   '8: T2 Trailing whitespace',
83    \ ])
84  
85    AssertEqual
86    \ [],
87    \ ale_linters#gitcommit#gitlint#Handle(bufnr(''), [
88    \   '8: B2 Trailing whitespace',
89    \ ])