]> git.madduck.net Git - etc/vim.git/blobdiff - .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 '76265755a1add77121c8f9dabb3e9bb70fe9a972' as '.vim/bundle/ale'
[etc/vim.git] / .vim / bundle / ale / test / handler / test_golangci_lint_handler.vader
diff --git a/.vim/bundle/ale/test/handler/test_golangci_lint_handler.vader b/.vim/bundle/ale/test/handler/test_golangci_lint_handler.vader
new file mode 100644 (file)
index 0000000..34f51d7
--- /dev/null
@@ -0,0 +1,146 @@
+Before:
+  runtime ale_linters/go/golangci_lint.vim
+
+After:
+  call ale#linter#Reset()
+
+Execute (The golangci-lint handler should handle only typecheck lines as errors):
+  call ale#test#SetFilename('app/main.go')
+
+  AssertEqual
+  \ [
+  \   {
+  \     'lnum': 1,
+  \     'col': 0,
+  \     'text': 'typecheck - found packages main (main.go) and validator (validation.go) in ',
+  \     'type': 'E',
+  \     'filename': ale#path#Simplify(expand('%:p:h') . '/main.go'),
+  \   },
+  \   {
+  \     'lnum': 1,
+  \     'col': 1,
+  \     'text': 'typecheck - package validator_test; expected package main_test',
+  \     'type': 'E',
+  \     'filename': ale#path#Simplify(expand('%:p:h') . '/validation_encoder_test.go'),
+  \   },
+  \   {
+  \     'lnum': 1,
+  \     'col': 1,
+  \     'text': 'typecheck - package validator_test; expected package main_test',
+  \     'type': 'E',
+  \     'filename': ale#path#Simplify(expand('%:p:h') . '/validation_error_test.go'),
+  \   },
+  \   {
+  \     'lnum': 505,
+  \     'col': 75,
+  \     'text': 'gomnd - Magic number: 404, in <argument> detected',
+  \     'type': 'W',
+  \     'filename': ale#path#Simplify(expand('%:p:h') . '/main.go'),
+  \   }
+  \ ],
+  \ ale_linters#go#golangci_lint#Handler(bufnr(''), [
+  \ '{',
+  \ '  "Issues": [',
+  \ '  {',
+  \ '    "FromLinter": "typecheck",',
+  \ '    "Text": "found packages main (main.go) and validator (validation.go) in ",',
+  \ '    "Severity": "",',
+  \ '    "SourceLines": [',
+  \ '      "package main"',
+  \ '    ],',
+  \ '    "Pos": {',
+  \ '      "Filename": "main.go",',
+  \ '      "Offset": 0,',
+  \ '      "Line": 1,',
+  \ '      "Column": 0',
+  \ '    },',
+  \ '    "ExpectNoLint": false,',
+  \ '    "ExpectedNoLintLinter": ""',
+  \ '  },',
+  \ '  {',
+  \ '    "FromLinter": "typecheck",',
+  \ '    "Text": "package validator_test; expected package main_test",',
+  \ '    "Severity": "",',
+  \ '    "SourceLines": [',
+  \ '      "package validator_test"',
+  \ '    ],',
+  \ '    "Pos": {',
+  \ '      "Filename": "validation_encoder_test.go",',
+  \ '      "Offset": 0,',
+  \ '      "Line": 1,',
+  \ '      "Column": 1',
+  \ '    },',
+  \ '    "ExpectNoLint": false,',
+  \ '    "ExpectedNoLintLinter": ""',
+  \ '  },',
+  \ '  {',
+  \ '    "FromLinter": "typecheck",',
+  \ '    "Text": "package validator_test; expected package main_test",',
+  \ '    "Severity": "",',
+  \ '    "SourceLines": [',
+  \ '      "package validator_test"',
+  \ '    ],',
+  \ '    "Pos": {',
+  \ '      "Filename": "validation_error_test.go",',
+  \ '      "Offset": 0,',
+  \ '      "Line": 1,',
+  \ '      "Column": 1',
+  \ '    },',
+  \ '    "ExpectNoLint": false,',
+  \ '    "ExpectedNoLintLinter": ""',
+  \ '  },',
+  \ '  {',
+  \ '    "FromLinter": "gomnd",',
+  \ '    "Text": "Magic number: 404, in <argument> detected",',
+  \ '    "Severity": "",',
+  \ '    "SourceLines": [',
+  \ '      "package validator_test"',
+  \ '    ],',
+  \ '    "Pos": {',
+  \ '      "Filename": "main.go",',
+  \ '      "Offset": 0,',
+  \ '      "Line": 505,',
+  \ '      "Column": 75',
+  \ '    },',
+  \ '    "ExpectNoLint": false,',
+  \ '    "ExpectedNoLintLinter": ""',
+  \ '    }',
+  \ '  ]',
+  \ '}',
+  \ ])
+
+Execute (The golangci-lint handler should set proper filename):
+  call ale#test#SetFilename('app/cmd/server/main.go')
+
+  AssertEqual
+  \ [
+  \   {
+  \     'lnum': 198,
+  \     'col': 19,
+  \     'text': 'funlen - Function getConfig has too many statements (51 > 50)',
+  \     'type': 'W',
+  \     'filename': ale#path#Simplify(expand('%:p:h') . '/main.go'),
+  \   },
+  \ ],
+  \ ale_linters#go#golangci_lint#Handler(bufnr(''), [
+  \ '{',
+  \ '  "Issues": [',
+  \ '  {',
+  \ '    "FromLinter": "funlen",',
+  \ '    "Text": "Function getConfig has too many statements (51 > 50)",',
+  \ '    "Severity": "",',
+  \ '    "SourceLines": [',
+  \ '      "package main"',
+  \ '    ],',
+  \ '    "Pos": {',
+  \ '      "Filename": "cmd/server/main.go",',
+  \ '      "Offset": 5374,',
+  \ '      "Line": 198,',
+  \ '      "Column": 19',
+  \ '    },',
+  \ '    "ExpectNoLint": false,',
+  \ '    "ExpectedNoLintLinter": ""',
+  \ '  }',
+  \ '  ]',
+  \ '}',
+  \ ])