2019-05-23 13:12:36 +00:00
|
|
|
Before:
|
|
|
|
" Load the file which defines the linter.
|
|
|
|
runtime ale_linters/terraform/terraform.vim
|
2021-03-20 22:11:22 +00:00
|
|
|
call ale#test#SetDirectory('/testplugin/test/test-files/terraform')
|
2021-01-30 08:11:12 +00:00
|
|
|
call ale#test#SetFilename('providers.tf')
|
2019-05-23 13:12:36 +00:00
|
|
|
|
|
|
|
After:
|
|
|
|
" Unload all linters again.
|
|
|
|
call ale#linter#Reset()
|
2021-01-30 08:11:12 +00:00
|
|
|
call ale#test#RestoreDirectory()
|
2019-05-23 13:12:36 +00:00
|
|
|
|
|
|
|
Execute(The output should be correct):
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ {
|
2021-01-30 08:11:12 +00:00
|
|
|
\ 'lnum': 17,
|
|
|
|
\ 'col': 13,
|
2021-01-30 09:17:28 +00:00
|
|
|
\ 'filename': ale#path#Simplify(g:dir . '/providers.tf'),
|
2021-01-30 08:11:12 +00:00
|
|
|
\ 'type': 'W',
|
|
|
|
\ 'text': 'Terraform 0.13 and earlier allowed provider version',
|
2019-05-23 13:12:36 +00:00
|
|
|
\ },
|
|
|
|
\ {
|
2021-01-30 08:11:12 +00:00
|
|
|
\ 'lnum': 0,
|
|
|
|
\ 'col': 0,
|
2021-01-30 09:17:28 +00:00
|
|
|
\ 'filename': ale#path#Simplify(g:dir . '/providers.tf'),
|
2019-05-23 13:12:36 +00:00
|
|
|
\ 'type': 'E',
|
2021-01-30 08:11:12 +00:00
|
|
|
\ 'text': 'Plugin reinitialization required. Please run "terraform"',
|
|
|
|
\ }
|
2019-05-23 13:12:36 +00:00
|
|
|
\ ],
|
|
|
|
\ ale_linters#terraform#terraform#Handle(bufnr(''), [
|
2021-01-30 08:11:12 +00:00
|
|
|
\ '{',
|
|
|
|
\ '"valid": false,',
|
|
|
|
\ '"error_count": 1,',
|
|
|
|
\ '"warning_count": 1,',
|
|
|
|
\ '"diagnostics": [',
|
|
|
|
\ ' {',
|
|
|
|
\ ' "severity": "warning",',
|
|
|
|
\ ' "summary": "Version constraints inside provider configuration blocks are deprecated",',
|
|
|
|
\ ' "detail": "Terraform 0.13 and earlier allowed provider version",',
|
|
|
|
\ ' "range": {',
|
|
|
|
\ ' "filename": "providers.tf",',
|
|
|
|
\ ' "start": {',
|
|
|
|
\ ' "line": 17,',
|
|
|
|
\ ' "column": 13,',
|
|
|
|
\ ' "byte": 669',
|
|
|
|
\ ' },',
|
|
|
|
\ ' "end": {',
|
|
|
|
\ ' "line": 17,',
|
|
|
|
\ ' "column": 24,',
|
|
|
|
\ ' "byte": 680',
|
|
|
|
\ ' }',
|
|
|
|
\ ' }',
|
|
|
|
\ ' },',
|
|
|
|
\ ' {',
|
|
|
|
\ ' "severity": "error",',
|
|
|
|
\ ' "summary": "Could not load plugin",',
|
|
|
|
\ ' "detail": "Plugin reinitialization required. Please run \"terraform\""',
|
|
|
|
\ ' }',
|
|
|
|
\ ' ]',
|
|
|
|
\ '}',
|
2019-05-23 13:12:36 +00:00
|
|
|
\ ])
|
2021-03-04 11:45:33 +00:00
|
|
|
|
|
|
|
Execute(Should use summary if detail not available):
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ {
|
|
|
|
\ 'lnum': 91,
|
|
|
|
\ 'col': 41,
|
|
|
|
\ 'filename': ale#path#Simplify(g:dir . '/main.tf'),
|
|
|
|
\ 'type': 'E',
|
|
|
|
\ 'text': 'storage_os_disk: required field is not set',
|
|
|
|
\ }
|
|
|
|
\ ],
|
|
|
|
\ ale_linters#terraform#terraform#Handle(bufnr(''), [
|
|
|
|
\ '{',
|
|
|
|
\ ' "valid": false,',
|
|
|
|
\ ' "error_count": 1,',
|
|
|
|
\ ' "warning_count": 0,',
|
|
|
|
\ ' "diagnostics": [',
|
|
|
|
\ ' {',
|
|
|
|
\ ' "severity": "error",',
|
|
|
|
\ ' "summary": "storage_os_disk: required field is not set",',
|
|
|
|
\ ' "range": {',
|
|
|
|
\ ' "filename": "main.tf",',
|
|
|
|
\ ' "start": {',
|
|
|
|
\ ' "line": 91,',
|
|
|
|
\ ' "column": 41,',
|
|
|
|
\ ' "byte": 2381',
|
|
|
|
\ ' },',
|
|
|
|
\ ' "end": {',
|
|
|
|
\ ' "line": 91,',
|
|
|
|
\ ' "column": 41,',
|
|
|
|
\ ' "byte": 2381',
|
|
|
|
\ ' }',
|
|
|
|
\ ' }',
|
|
|
|
\ ' }',
|
|
|
|
\ ' ]',
|
|
|
|
\ '}'
|
|
|
|
\ ])
|