]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/test/handler/test_golangci_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 'd49e95aa7ba744f0a7f544aca43afdb6aab41f24' as '.vim/bundle/asyncomplete...
[etc/vim.git] / .vim / bundle / ale / test / handler / 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 only typecheck lines as errors):
8   call ale#test#SetFilename('app/main.go')
9
10   AssertEqual
11   \ [
12   \   {
13   \     'lnum': 1,
14   \     'col': 0,
15   \     'text': 'typecheck - found packages main (main.go) and validator (validation.go) in ',
16   \     'type': 'E',
17   \     'filename': ale#path#Simplify(expand('%:p:h') . '/main.go'),
18   \   },
19   \   {
20   \     'lnum': 1,
21   \     'col': 1,
22   \     'text': 'typecheck - package validator_test; expected package main_test',
23   \     'type': 'E',
24   \     'filename': ale#path#Simplify(expand('%:p:h') . '/validation_encoder_test.go'),
25   \   },
26   \   {
27   \     'lnum': 1,
28   \     'col': 1,
29   \     'text': 'typecheck - package validator_test; expected package main_test',
30   \     'type': 'E',
31   \     'filename': ale#path#Simplify(expand('%:p:h') . '/validation_error_test.go'),
32   \   },
33   \   {
34   \     'lnum': 505,
35   \     'col': 75,
36   \     'text': 'gomnd - Magic number: 404, in <argument> detected',
37   \     'type': 'W',
38   \     'filename': ale#path#Simplify(expand('%:p:h') . '/main.go'),
39   \   }
40   \ ],
41   \ ale_linters#go#golangci_lint#Handler(bufnr(''), [
42   \ '{',
43   \ '  "Issues": [',
44   \ '  {',
45   \ '    "FromLinter": "typecheck",',
46   \ '    "Text": "found packages main (main.go) and validator (validation.go) in ",',
47   \ '    "Severity": "",',
48   \ '    "SourceLines": [',
49   \ '      "package main"',
50   \ '    ],',
51   \ '    "Pos": {',
52   \ '      "Filename": "main.go",',
53   \ '      "Offset": 0,',
54   \ '      "Line": 1,',
55   \ '      "Column": 0',
56   \ '    },',
57   \ '    "ExpectNoLint": false,',
58   \ '    "ExpectedNoLintLinter": ""',
59   \ '  },',
60   \ '  {',
61   \ '    "FromLinter": "typecheck",',
62   \ '    "Text": "package validator_test; expected package main_test",',
63   \ '    "Severity": "",',
64   \ '    "SourceLines": [',
65   \ '      "package validator_test"',
66   \ '    ],',
67   \ '    "Pos": {',
68   \ '      "Filename": "validation_encoder_test.go",',
69   \ '      "Offset": 0,',
70   \ '      "Line": 1,',
71   \ '      "Column": 1',
72   \ '    },',
73   \ '    "ExpectNoLint": false,',
74   \ '    "ExpectedNoLintLinter": ""',
75   \ '  },',
76   \ '  {',
77   \ '    "FromLinter": "typecheck",',
78   \ '    "Text": "package validator_test; expected package main_test",',
79   \ '    "Severity": "",',
80   \ '    "SourceLines": [',
81   \ '      "package validator_test"',
82   \ '    ],',
83   \ '    "Pos": {',
84   \ '      "Filename": "validation_error_test.go",',
85   \ '      "Offset": 0,',
86   \ '      "Line": 1,',
87   \ '      "Column": 1',
88   \ '    },',
89   \ '    "ExpectNoLint": false,',
90   \ '    "ExpectedNoLintLinter": ""',
91   \ '  },',
92   \ '  {',
93   \ '    "FromLinter": "gomnd",',
94   \ '    "Text": "Magic number: 404, in <argument> detected",',
95   \ '    "Severity": "",',
96   \ '    "SourceLines": [',
97   \ '      "package validator_test"',
98   \ '    ],',
99   \ '    "Pos": {',
100   \ '      "Filename": "main.go",',
101   \ '      "Offset": 0,',
102   \ '      "Line": 505,',
103   \ '      "Column": 75',
104   \ '    },',
105   \ '    "ExpectNoLint": false,',
106   \ '    "ExpectedNoLintLinter": ""',
107   \ '    }',
108   \ '  ]',
109   \ '}',
110   \ ])
111
112 Execute (The golangci-lint handler should set proper filename):
113   call ale#test#SetFilename('app/cmd/server/main.go')
114
115   AssertEqual
116   \ [
117   \   {
118   \     'lnum': 198,
119   \     'col': 19,
120   \     'text': 'funlen - Function getConfig has too many statements (51 > 50)',
121   \     'type': 'W',
122   \     'filename': ale#path#Simplify(expand('%:p:h') . '/main.go'),
123   \   },
124   \ ],
125   \ ale_linters#go#golangci_lint#Handler(bufnr(''), [
126   \ '{',
127   \ '  "Issues": [',
128   \ '  {',
129   \ '    "FromLinter": "funlen",',
130   \ '    "Text": "Function getConfig has too many statements (51 > 50)",',
131   \ '    "Severity": "",',
132   \ '    "SourceLines": [',
133   \ '      "package main"',
134   \ '    ],',
135   \ '    "Pos": {',
136   \ '      "Filename": "cmd/server/main.go",',
137   \ '      "Offset": 5374,',
138   \ '      "Line": 198,',
139   \ '      "Column": 19',
140   \ '    },',
141   \ '    "ExpectNoLint": false,',
142   \ '    "ExpectedNoLintLinter": ""',
143   \ '  }',
144   \ '  ]',
145   \ '}',
146   \ ])