/ test / handler / test_golangci_lint_handler.vader
test_golangci_lint_handler.vader
 1  Before:
 2    runtime ale_linters/go/golangci_lint.vim
 3  
 4  After:
 5    call ale#linter#Reset()
 6  
 7  Execute (The golangci-lint handler should handle names with spaces):
 8    " We can't test Windows paths with the path resovling on Linux, but we can
 9    " test the regex.
10    AssertEqual
11    \ [
12    \   [
13    \     'C:\something\file with spaces.go',
14    \     '12',
15    \     '3',
16    \     'expected ''package'', found ''IDENT'' gibberish',
17    \     'staticcheck',
18    \   ],
19    \ ],
20    \ map(ale_linters#go#golangci_lint#GetMatches([
21    \   'C:\something\file with spaces.go:12:3: expected ''package'', found ''IDENT'' gibberish (staticcheck)',
22    \ ]), 'v:val[1:5]')
23  
24  Execute (The golangci-lint handler should handle paths correctly):
25    call ale#test#SetFilename('app/test.go')
26  
27    let file = ale#path#GetAbsPath(expand('%:p:h'), 'test.go')
28  
29    AssertEqual
30    \ [
31    \   {
32    \     'lnum': 12,
33    \     'col': 3,
34    \     'text': 'expected ''package'', found ''IDENT'' gibberish (staticcheck)',
35    \     'type': 'W',
36    \     'filename': ale#path#Simplify(expand('%:p:h') . '/test.go'),
37    \   },
38    \ ],
39    \ ale_linters#go#golangci_lint#Handler(bufnr(''), [
40    \   file . ':12:3: expected ''package'', found ''IDENT'' gibberish (staticcheck)',
41    \ ])
42  
43  Execute (The golangci-lint handler should handle only typecheck lines as errors):
44    call ale#test#SetFilename('app/main.go')
45  
46    AssertEqual
47    \ [
48    \   {
49    \     'lnum': 30,
50    \     'col': 5,
51    \     'text': 'variable ''err'' is not used (typecheck)',
52    \     'type': 'E',
53    \     'filename': ale#path#Simplify(expand('%:p:h') . '/test.go'),
54    \   },
55    \   {
56    \     'lnum': 505,
57    \     'col': 75,
58    \     'text': 'Magic number: 404, in <argument> detected (gomnd)',
59    \     'type': 'W',
60    \     'filename': ale#path#Simplify(expand('%:p:h') . '/test.go'),
61    \   }
62    \ ],
63    \ ale_linters#go#golangci_lint#Handler(bufnr(''), [
64    \   ale#path#GetAbsPath(expand('%:p:h'), 'test.go') . ':30:5: variable ''err'' is not used (typecheck)',
65    \   ale#path#GetAbsPath(expand('%:p:h'), 'test.go') . ':505:75: Magic number: 404, in <argument> detected (gomnd)',
66    \ ])