summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNathaniel Williams <nat@livewatch.com>2017-10-26 19:32:33 +0100
committerw0rp <devw0rp@gmail.com>2017-10-26 19:37:04 +0100
commite4456a4e0e9622baf2af30acd34a28963df5f4fa (patch)
tree5ae24057300cbcafa576f6ca81903168133f6659 /test
parent6ed456f99c46ad6853fdd893344e94060ce9f6c3 (diff)
downloadale-e4456a4e0e9622baf2af30acd34a28963df5f4fa.zip
Add tflint fot Terraform
Diffstat (limited to 'test')
-rw-r--r--test/command_callback/test_terraform_tflint_command_callback.vader32
-rw-r--r--test/handler/test_tflint_handler.vader28
-rw-r--r--test/test_tflint_config_detection.vader18
-rw-r--r--test/tflint-test-files/foo/.tflint.hcl0
-rw-r--r--test/tflint-test-files/foo/bar.tf0
5 files changed, 78 insertions, 0 deletions
diff --git a/test/command_callback/test_terraform_tflint_command_callback.vader b/test/command_callback/test_terraform_tflint_command_callback.vader
new file mode 100644
index 00000000..ba768152
--- /dev/null
+++ b/test/command_callback/test_terraform_tflint_command_callback.vader
@@ -0,0 +1,32 @@
+Before:
+
+ Save g:ale_terraform_tflint_executable
+ Save g:ale_terraform_tflint_options
+
+ runtime ale_linters/terraform/tflint.vim
+
+
+After:
+ Restore
+ call ale#linter#Reset()
+
+
+Execute(The default executable should be configurable):
+ AssertEqual 'tflint', ale_linters#terraform#tflint#GetExecutable(bufnr(''))
+
+ let g:ale_terraform_tflint_executable = 'asdf'
+
+ AssertEqual 'asdf', ale_linters#terraform#tflint#GetExecutable(bufnr(''))
+
+Execute(The default command should be good):
+ let g:ale_terraform_tflint_executable = 'tflint'
+ AssertEqual
+ \ ale#Escape('tflint') . ' -f json',
+ \ ale_linters#terraform#tflint#GetCommand(bufnr(''))
+
+Execute(Overriding things should work):
+ let g:ale_terraform_tflint_executable = 'fnord'
+ let g:ale_terraform_tflint_options = '--whatever'
+ AssertEqual
+ \ ale#Escape('fnord') . ' --whatever -f json',
+ \ ale_linters#terraform#tflint#GetCommand(bufnr(''))
diff --git a/test/handler/test_tflint_handler.vader b/test/handler/test_tflint_handler.vader
new file mode 100644
index 00000000..95671b8a
--- /dev/null
+++ b/test/handler/test_tflint_handler.vader
@@ -0,0 +1,28 @@
+Before:
+ runtime! ale_linters/terraform/tflint.vim
+
+After:
+ call ale#linter#Reset()
+
+Execute(The tflint handler should parse items correctly):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 12,
+ \ 'text': 'be warned, traveller',
+ \ 'type': 'W',
+ \ },
+ \ {
+ \ 'lnum': 9,
+ \ 'text': 'error message',
+ \ 'type': 'E',
+ \ },
+ \ {
+ \ 'lnum': 5,
+ \ 'text': 'just so ya know',
+ \ 'type': 'I',
+ \ },
+ \ ],
+ \ ale_linters#terraform#tflint#Handle(123, [
+ \ '[ { "detector": "aws_db_instance_readable_password", "type": "WARNING", "message": "be warned, traveller", "line": 12, "file": "github.com/wata727/example-module/aws_db_instance.tf", "link": "https://github.com/wata727/tflint/blob/master/docs/aws_db_instance_readable_password.md" }, { "detector": "aws_elasticache_cluster_invalid_type", "type": "ERROR", "message": "error message", "line": 9, "file": "github.com/wata727/example-module/aws_elasticache_cluster.tf", "link": "https://github.com/wata727/tflint/blob/master/docs/aws_elasticache_cluster_invalid_type.md" }, { "detector": "aws_instance_not_specified_iam_profile", "type": "NOTICE", "message": "just so ya know", "line": 5, "file": "github.com/wata727/example-module/aws_instance.tf", "link": "https://github.com/wata727/tflint/blob/master/docs/aws_instance_not_specified_iam_profile.md" } ]'
+ \ ])
diff --git a/test/test_tflint_config_detection.vader b/test/test_tflint_config_detection.vader
new file mode 100644
index 00000000..ac64c031
--- /dev/null
+++ b/test/test_tflint_config_detection.vader
@@ -0,0 +1,18 @@
+Before:
+ call ale#test#SetDirectory('/testplugin/test')
+ runtime ale_linters/terraform/tflint.vim
+
+After:
+ call ale#test#RestoreDirectory()
+ call ale#linter#Reset()
+
+Execute(adjacent config file should be found):
+ call ale#test#SetFilename('tflint-test-files/foo/bar.tf')
+ AssertEqual
+ \ (
+ \ ale#Escape('tflint')
+ \ . ' --config '
+ \ . ale#Escape(ale#path#Winify(g:dir . '/tflint-test-files/foo/.tflint.hcl'))
+ \ . ' -f json'
+ \ ),
+ \ ale_linters#terraform#tflint#GetCommand(bufnr(''))
diff --git a/test/tflint-test-files/foo/.tflint.hcl b/test/tflint-test-files/foo/.tflint.hcl
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/tflint-test-files/foo/.tflint.hcl
diff --git a/test/tflint-test-files/foo/bar.tf b/test/tflint-test-files/foo/bar.tf
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/tflint-test-files/foo/bar.tf