summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorReza J. Bavaghoush <rzjfr@users.noreply.github.com>2022-05-16 14:14:11 +0200
committerGitHub <noreply@github.com>2022-05-16 21:14:11 +0900
commit75d241342532e5acf34caff28a7a9e5cda688a32 (patch)
tree3faa2cd8c2b52d32751c577e3a5a29faeddd08e0 /test
parent5479b58660906041d67544a025522a39e006b184 (diff)
downloadale-75d241342532e5acf34caff28a7a9e5cda688a32.zip
add rego support (#4199)
* add opa fmt fixer for rego files * add opa linter * add basic tests for linter and fixer * add cspell to the docs
Diffstat (limited to 'test')
-rw-r--r--test/fixers/test_opa_fmt_fixer_callback.vader33
-rw-r--r--test/linter/test_rego_opacheck.vader16
2 files changed, 49 insertions, 0 deletions
diff --git a/test/fixers/test_opa_fmt_fixer_callback.vader b/test/fixers/test_opa_fmt_fixer_callback.vader
new file mode 100644
index 00000000..3b112b2e
--- /dev/null
+++ b/test/fixers/test_opa_fmt_fixer_callback.vader
@@ -0,0 +1,33 @@
+Before:
+ Save g:ale_opa_fmt_executable
+ Save g:ale_opa_fmt_options
+
+ " Use an invalid global executable, so we don't match it.
+ let g:ale_opa_fmt_executable = 'xxxinvalid'
+ let g:ale_opa_fmt_options = ''
+
+ call ale#test#SetDirectory('/testplugin/test/fixers')
+
+After:
+ Restore
+
+ call ale#test#RestoreDirectory()
+
+Execute(The opa fmt callback should return the correct default values):
+
+ AssertEqual
+ \ {
+ \ 'command': ale#Escape('xxxinvalid') . ' fmt',
+ \ },
+ \ ale#fixers#opafmt#Fix(bufnr(''))
+
+Execute(The opa fmt callback should include custom options):
+ let g:ale_opa_fmt_options = "--list"
+
+ AssertEqual
+ \ {
+ \ 'command': ale#Escape('xxxinvalid')
+ \ . ' fmt'
+ \ . ' ' . g:ale_opa_fmt_options
+ \ },
+ \ ale#fixers#opafmt#Fix(bufnr(''))
diff --git a/test/linter/test_rego_opacheck.vader b/test/linter/test_rego_opacheck.vader
new file mode 100644
index 00000000..886a9339
--- /dev/null
+++ b/test/linter/test_rego_opacheck.vader
@@ -0,0 +1,16 @@
+
+" Based upon :help ale-development
+Before:
+ call ale#assert#SetUpLinterTest('rego', 'opacheck')
+
+After:
+ call ale#assert#TearDownLinterTest()
+
+Execute(The default command should be correct):
+ AssertLinter 'opa',
+ \ ale#Escape('opa') . ' check %s --format json '
+
+Execute(The default command should be overriden):
+ let b:ale_rego_opacheck_executable = '/bin/other/opa'
+ AssertLinter '/bin/other/opa',
+ \ ale#Escape('/bin/other/opa') . ' check %s --format json '