diff options
author | Reza J. Bavaghoush <rzjfr@users.noreply.github.com> | 2022-05-16 14:14:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-16 21:14:11 +0900 |
commit | 75d241342532e5acf34caff28a7a9e5cda688a32 (patch) | |
tree | 3faa2cd8c2b52d32751c577e3a5a29faeddd08e0 /test | |
parent | 5479b58660906041d67544a025522a39e006b184 (diff) | |
download | ale-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.vader | 33 | ||||
-rw-r--r-- | test/linter/test_rego_opacheck.vader | 16 |
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 ' |