diff options
Diffstat (limited to 'test/handler')
-rw-r--r-- | test/handler/test_dockerfile_lint_handler.vader | 108 | ||||
-rw-r--r-- | test/handler/test_swipl_handler.vader | 95 |
2 files changed, 203 insertions, 0 deletions
diff --git a/test/handler/test_dockerfile_lint_handler.vader b/test/handler/test_dockerfile_lint_handler.vader new file mode 100644 index 00000000..619b7bde --- /dev/null +++ b/test/handler/test_dockerfile_lint_handler.vader @@ -0,0 +1,108 @@ +Before: + runtime ale_linters/dockerfile/dockerfile_lint.vim + +After: + call ale#linter#Reset() + +Execute(The dockerfile_lint handler should handle broken JSON): + AssertEqual + \ [], + \ ale_linters#dockerfile#dockerfile_lint#Handle(bufnr(''), ["{asdf"]) + +Execute(The dockerfile_lint handler should handle an empty string response): + AssertEqual + \ [], + \ ale_linters#dockerfile#dockerfile_lint#Handle(bufnr(''), []) + +Execute(The dockerfile_lint handler should handle an empty result, even if it shouldn't happen): + AssertEqual + \ [], + \ ale_linters#dockerfile#dockerfile_lint#Handle(bufnr(''), ["{}"]) + +Execute(The dockerfile_lint handler should handle a normal example): + AssertEqual + \ [ + \ { + \ 'lnum': -1, + \ 'type': 'E', + \ 'text': "Required LABEL name/key 'Name' is not defined", + \ }, + \ { + \ 'lnum': -1, + \ 'type': 'E', + \ 'text': "Required LABEL name/key 'Version' is not defined", + \ }, + \ { + \ 'lnum': 3, + \ 'type': 'I', + \ 'text': "the MAINTAINER command is deprecated. MAINTAINER is deprecated in favor of using LABEL since Docker v1.13.0", + \ }, + \ { + \ 'lnum': -1, + \ 'type': 'I', + \ 'text': "There is no 'CMD' instruction", + \ }, + \ ], + \ ale_linters#dockerfile#dockerfile_lint#Handle(bufnr(''), [ + \ '{', + \ ' "error": {', + \ ' "count": 2,', + \ ' "data": [', + \ ' {', + \ " \"message\": \"Required LABEL name/key 'Name' is not defined\",", + \ ' "line": -1,', + \ ' "level": "error",', + \ ' "lineContent": "",', + \ ' "reference_url": [', + \ ' "http://docs.projectatomic.io/container-best-practices/#",', + \ ' "_recommended_labels_for_your_project"', + \ ' ]', + \ ' },', + \ ' {', + \ " \"message\": \"Required LABEL name/key 'Version' is not defined\",", + \ ' "line": -1,', + \ ' "level": "error",', + \ ' "lineContent": "",', + \ ' "reference_url": [', + \ ' "http://docs.projectatomic.io/container-best-practices/#",', + \ ' "_recommended_labels_for_your_project"', + \ ' ]', + \ ' }', + \ ' ]', + \ ' },', + \ ' "warn": {', + \ ' "count": 0,', + \ ' "data": []', + \ ' },', + \ ' "info": {', + \ ' "count": 2,', + \ ' "data": [', + \ ' {', + \ ' "label": "maintainer_deprecated",', + \ ' "regex": {},', + \ ' "level": "info",', + \ ' "message": "the MAINTAINER command is deprecated",', + \ ' "description": "MAINTAINER is deprecated in favor of using LABEL since Docker v1.13.0",', + \ ' "reference_url": [', + \ ' "https://github.com/docker/cli/blob/master/docs/deprecated.md",', + \ ' "#maintainer-in-dockerfile"', + \ ' ],', + \ ' "lineContent": "MAINTAINER Alexander Olofsson <ace@haxalot.com>",', + \ ' "line": 3', + \ ' },', + \ ' {', + \ ' "instruction": "CMD",', + \ ' "count": 1,', + \ ' "level": "info",', + \ " \"message\": \"There is no 'CMD' instruction\",", + \ ' "description": "None",', + \ ' "reference_url": [', + \ ' "https://docs.docker.com/engine/reference/builder/",', + \ ' "#cmd"', + \ ' ]', + \ ' }', + \ ' ]', + \ ' },', + \ ' "summary": []', + \ '}', + \ ]) diff --git a/test/handler/test_swipl_handler.vader b/test/handler/test_swipl_handler.vader new file mode 100644 index 00000000..9e425cf6 --- /dev/null +++ b/test/handler/test_swipl_handler.vader @@ -0,0 +1,95 @@ +Before: + runtime ale_linters/prolog/swipl.vim + +After: + call ale#linter#Reset() + +Execute (The swipl handler should handle oneline warning / error): + call ale#test#SetFilename('test.pl') + AssertEqual + \ [ + \ { + \ 'lnum': 5, + \ 'col': 1, + \ 'text': 'Syntax error: Operator expected', + \ 'type': 'E', + \ }, + \ ], + \ ale_linters#prolog#swipl#Handle(bufnr(''), [ + \ 'ERROR: /path/to/test.pl:5:1: Syntax error: Operator expected', + \ ]) + +Execute (The swipl handler should handle a warning / error of two lines): + call ale#test#SetFilename('test.pl') + AssertEqual + \ [ + \ { + \ 'lnum': 9, + \ 'col': 0, + \ 'text': 'Singleton variables: [M]', + \ 'type': 'W', + \ }, + \ ], + \ ale_linters#prolog#swipl#Handle(bufnr(''), [ + \ 'Warning: /path/to/test.pl:9:', + \ ' Singleton variables: [M]', + \ ]) + +Execute (The swipl handler should join three or more lines with '. '): + call ale#test#SetFilename('test.pl') + AssertEqual + \ [ + \ { + \ 'lnum': 10, + \ 'col': 0, + \ 'text': 'Clauses of fib/2 are not together in the source-file. Earlier definition at /path/to/test.pl:7. Current predicate: f/0. Use :- discontiguous fib/2. to suppress this message', + \ 'type': 'W', + \ }, + \ ], + \ ale_linters#prolog#swipl#Handle(bufnr(''), [ + \ 'Warning: /path/to/test.pl:10:', + \ ' Clauses of fib/2 are not together in the source-file', + \ ' Earlier definition at /path/to/test.pl:7', + \ ' Current predicate: f/0', + \ ' Use :- discontiguous fib/2. to suppress this message', + \ ]) + +Execute (The swipl handler should ignore warnings / errors 'No permission to call sandboxed ...'): + call ale#test#SetFilename('test.pl') + AssertEqual + \ [], + \ ale_linters#prolog#swipl#Handle(bufnr(''), [ + \ 'ERROR: /path/to/test.pl:11:', + \ ' No permission to call sandboxed `''$set_predicate_attribute''(_G3416:_G3417,_G3413,_G3414)''', + \ ' Reachable from:', + \ ' system:''$set_pattr''(A,B,C,D)', + \ ' system:''$set_pattr''(vimscript:A,B,C)', + \ ' vimscript: (multifile A)', + \ 'ERROR: /path/to/test.pl:12:', + \ ' No permission to call sandboxed `''$set_predicate_attribute''(_G205:_G206,_G202,_G203)''', + \ ' Reachable from:', + \ ' system:''$set_pattr''(A,B,C,D)', + \ ' system:''$set_pattr''(vimscript:A,B,C)', + \ ' vimscript: (multifile A)', + \ 'ERROR: /path/to/test.pl:13:', + \ ' No permission to call sandboxed `''$set_predicate_attribute''(_G1808:_G1809,_G1805,_G1806)''', + \ ' Reachable from:', + \ ' system:''$set_pattr''(A,B,C,D)', + \ ' system:''$set_pattr''(vimscript:A,B,C)', + \ ' vimscript: (multifile A)', + \ ]) + +Execute (The swipl handler should handle a warning / error with no line number): + call ale#test#SetFilename('test.pl') + AssertEqual + \ [ + \ { + \ 'lnum': 1, + \ 'col': 0, + \ 'text': 'Exported procedure module_name:pred/0 is not defined', + \ 'type': 'E', + \ }, + \ ], + \ ale_linters#prolog#swipl#Handle(bufnr(''), [ + \ 'ERROR: Exported procedure module_name:pred/0 is not defined', + \ ]) |