summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorShad <shadow.walker@free.fr>2023-05-22 04:58:59 +0200
committerGitHub <noreply@github.com>2023-05-22 11:58:59 +0900
commita46121a532b2baaa339016ab910c59f1cded46e5 (patch)
tree85c5a66a2e6651ff0e9613612d92b7d2b4e63ccd /test
parent5c803fb970c30e6bdfc9d38f0c72eb42b572cb68 (diff)
downloadale-a46121a532b2baaa339016ab910c59f1cded46e5.zip
Dockerlinter (#4518)
* dockerlinter support * Tests & ShellCheck reference * sort and align docs
Diffstat (limited to 'test')
-rw-r--r--test/handler/test_dockerlinter_handler.vader77
-rw-r--r--test/linter/test_dockerlinter.vader19
2 files changed, 96 insertions, 0 deletions
diff --git a/test/handler/test_dockerlinter_handler.vader b/test/handler/test_dockerlinter_handler.vader
new file mode 100644
index 00000000..de59faac
--- /dev/null
+++ b/test/handler/test_dockerlinter_handler.vader
@@ -0,0 +1,77 @@
+Before:
+ runtime ale_linters/dockerfile/dockerlinter.vim
+
+After:
+ call ale#linter#Reset()
+
+Execute(The dockerlinter handler should handle broken JSON):
+ AssertEqual
+ \ [],
+ \ ale_linters#dockerfile#dockerlinter#Handle(bufnr(''), ["{asdf"])
+
+Execute(The dockerlinter handler should handle an empty string response):
+ AssertEqual
+ \ [],
+ \ ale_linters#dockerfile#dockerlinter#Handle(bufnr(''), [])
+
+Execute(The dockerlinter handler should handle an empty result, even if it shouldn't happen):
+ AssertEqual
+ \ [],
+ \ ale_linters#dockerfile#dockerlinter#Handle(bufnr(''), ["{}"])
+
+Execute(The dockerlinter handler should handle a normal example):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 11,
+ \ 'type': 'I',
+ \ 'code': 'ER0002',
+ \ 'text': "Delete the apt-get lists after installing something",
+ \ 'detail': "Delete the apt-get lists after installing something\n\nhttps://github.com/buddy-works/dockerfile-linter/blob/master/Rules.md#ER0002",
+ \ },
+ \ {
+ \ 'lnum': 11,
+ \ 'type': 'I',
+ \ 'code': 'ER0010',
+ \ 'text': "Avoid additional packages by specifying --no-install-recommends",
+ \ 'detail': "Avoid additional packages by specifying --no-install-recommends\n\nhttps://github.com/buddy-works/dockerfile-linter/blob/master/Rules.md#ER0010",
+ \ },
+ \ {
+ \ 'lnum': 11,
+ \ 'type': 'I',
+ \ 'code': 'ER0012',
+ \ 'text': "Pin versions in apt get install",
+ \ 'detail': "Pin versions in apt get install\n\nhttps://github.com/buddy-works/dockerfile-linter/blob/master/Rules.md#ER0012",
+ \ },
+ \ {
+ \ 'lnum': 30,
+ \ 'type': 'W',
+ \ 'code': 'SC2155',
+ \ 'text': "Declare and assign separately to avoid masking return values.",
+ \ 'detail': "Declare and assign separately to avoid masking return values.\n\nhttps://www.shellcheck.net/wiki/SC2155",
+ \ },
+ \ {
+ \ 'lnum': 30,
+ \ 'type': 'W',
+ \ 'code': 'SC2046',
+ \ 'text': "Quote this to prevent word splitting.",
+ \ 'detail': "Quote this to prevent word splitting.\n\nhttps://www.shellcheck.net/wiki/SC2046",
+ \ },
+ \ {
+ \ 'lnum': 30,
+ \ 'type': 'I',
+ \ 'code': 'SC2086',
+ \ 'text': "Double quote to prevent globbing and word splitting.",
+ \ 'detail': "Double quote to prevent globbing and word splitting.\n\nhttps://www.shellcheck.net/wiki/SC2086",
+ \ },
+ \ {
+ \ 'lnum': 31,
+ \ 'type': 'W',
+ \ 'code': 'SC2046',
+ \ 'text': "Quote this to prevent word splitting.",
+ \ 'detail': "Quote this to prevent word splitting.\n\nhttps://www.shellcheck.net/wiki/SC2046",
+ \ },
+ \ ],
+ \ ale_linters#dockerfile#dockerlinter#Handle(bufnr(''), [
+ \ '[{"lineNumber":11,"message":"Delete the apt-get lists after installing something","level":"info","code":"ER0002"},{"lineNumber":11,"message":"Avoid additional packages by specifying --no-install-recommends","level":"info","code":"ER0010"},{"lineNumber":11,"message":"Pin versions in apt get install","level":"info","code":"ER0012"},{"lineNumber":30,"message":"Declare and assign separately to avoid masking return values.","level":"warning","code":"SC2155"},{"lineNumber":30,"message":"Quote this to prevent word splitting.","level":"warning","code":"SC2046"},{"lineNumber":30,"message":"Double quote to prevent globbing and word splitting.","level":"info","code":"SC2086"},{"lineNumber":31,"message":"Quote this to prevent word splitting.","level":"warning","code":"SC2046"}]',
+ \ ])
diff --git a/test/linter/test_dockerlinter.vader b/test/linter/test_dockerlinter.vader
new file mode 100644
index 00000000..a7077221
--- /dev/null
+++ b/test/linter/test_dockerlinter.vader
@@ -0,0 +1,19 @@
+Before:
+ call ale#assert#SetUpLinterTest('dockerfile', 'dockerlinter')
+
+After:
+ call ale#assert#TearDownLinterTest()
+
+Execute(The default command should be correct):
+ AssertLinter 'dockerlinter', ale#Escape('dockerlinter') . ' -j -f %t'
+
+Execute(The executable should be configurable):
+ let b:ale_dockerfile_dockerlinter_executable = 'foobar'
+
+ AssertLinter 'foobar', ale#Escape('foobar') . ' -j -f %t'
+
+Execute(The options should be configurable):
+ let b:ale_dockerfile_dockerlinter_options = '-r additional.yaml'
+
+ AssertLinter 'dockerlinter', ale#Escape('dockerlinter') . ' -r additional.yaml -j -f %t'
+