/ test / handler / test_hadolint.vader
test_hadolint.vader
 1  Before:
 2    runtime ale_linters/dockerfile/hadolint.vim
 3  
 4  After:
 5    call ale#linter#Reset()
 6  
 7  Execute(The hadolint handler should handle an empty string response):
 8    AssertEqual
 9    \ [],
10    \ ale_linters#dockerfile#hadolint#Handle(bufnr(''), [])
11  
12  Execute(The hadolint handler should handle a normal example):
13    AssertEqual
14    \ [
15    \   {
16    \     'lnum': 1,
17    \     'col': 0,
18    \     'type': 'W',
19    \     'code': 'DL3006',
20    \     'text': "DL3006: Always tag the version of an image explicitly",
21    \     'detail': "DL3006 ( https://github.com/hadolint/hadolint/wiki/DL3006 )\n\nAlways tag the version of an image explicitly",
22    \   },
23    \   {
24    \     'lnum': 4,
25    \     'col': 0,
26    \     'type': 'W',
27    \     'code': 'DL3033',
28    \     'text': "DL3033: Specify version with `yum install -y <package>-<version>`.",
29    \     'detail': "DL3033 ( https://github.com/hadolint/hadolint/wiki/DL3033 )\n\nSpecify version with `yum install -y <package>-<version>`.",
30    \   },
31    \   {
32    \     'lnum': 12,
33    \     'col': 0,
34    \     'type': 'W',
35    \     'code': 'SC2039',
36    \     'text': "SC2039: In POSIX sh, brace expansion is undefined.",
37    \     'detail': "SC2039 ( https://github.com/koalaman/shellcheck/wiki/SC2039 )\n\nIn POSIX sh, brace expansion is undefined.",
38    \   },
39    \ ],
40    \ ale_linters#dockerfile#hadolint#Handle(bufnr(''), [
41    \ '-:1 DL3006 warning: Always tag the version of an image explicitly',
42    \ '-:4 DL3033 warning: Specify version with `yum install -y <package>-<version>`.',
43    \ '-:12 SC2039 warning: In POSIX sh, brace expansion is undefined.',
44    \ ])
45  
46  Execute(The hadolint handler should handle parsing errors):
47    AssertEqual
48    \ [
49    \   {
50    \     'lnum': 1,
51    \     'col': 1,
52    \     'type': 'E',
53    \     'text': "unexpected 'b' expecting '#', ADD, ARG, CMD, COPY, ENTRYPOINT, ENV, EXPOSE, FROM, HEALTHCHECK, LABEL, MAINTAINER, ONBUILD, RUN, SHELL, STOPSIGNAL, USER, VOLUME, WORKDIR, or end of input",
54    \     'detail': "hadolint could not parse the file because of a syntax error.",
55    \   },
56    \ ],
57    \ ale_linters#dockerfile#hadolint#Handle(bufnr(''), [
58    \ '/dev/stdin:1:1 unexpected ''b'' expecting ''#'', ADD, ARG, CMD, COPY, ENTRYPOINT, ENV, EXPOSE, FROM, HEALTHCHECK, LABEL, MAINTAINER, ONBUILD, RUN, SHELL, STOPSIGNAL, USER, VOLUME, WORKDIR, or end of input',
59    \ ])