/ test / handler / test_sql_sqlfluff_handler.vader
test_sql_sqlfluff_handler.vader
 1  Before:
 2    runtime ale_linters/sql/sqlfluff.vim
 3  
 4  After:
 5    call ale#linter#Reset()
 6  
 7  Execute(The sqlfluff handler should handle basic warnings with version older than 3.0.0):
 8    AssertEqual
 9    \ [
10    \   {
11    \     'filename': 'schema.sql',
12    \     'lnum': 1,
13    \     'col': 8,
14    \     'type': 'W',
15    \     'code': 'L010',
16    \     'text': 'Keywords must be consistently upper case.',
17    \   },
18    \   {
19    \     'filename': 'schema.sql',
20    \     'lnum': 13,
21    \     'col': 2,
22    \     'type': 'W',
23    \     'code': 'L003',
24    \     'text': 'Expected 1 indentation, found 0 [compared to line 12]',
25    \   },
26    \   {
27    \     'filename': 'schema.sql',
28    \     'lnum': 16,
29    \     'col': 1,
30    \     'type': 'W',
31    \     'code': 'L009',
32    \     'text': 'Files must end with a single trailing newline.',
33    \   },
34    \ ],
35    \ ale_linters#sql#sqlfluff#Handle(bufnr(''), [2, 3, 5], [
36    \    '[{"filepath": "schema.sql", "violations": [{"line_no": 1, "line_pos": 8, "code": "L010", "description": "Keywords must be consistently upper case."}, {"line_no": 13, "line_pos": 2, "code": "L003", "description": "Expected 1 indentation, found 0 [compared to line 12]"}, {"line_no": 16, "line_pos": 1, "code": "L009", "description": "Files must end with a single trailing newline."}]}]',
37    \ ])
38  
39  Execute(The sqlfluff handler should handle basic warnings with version newer than 3.0.0):
40    AssertEqual
41    \ [
42    \   {
43    \     'filename': 'schema.sql',
44    \     'lnum': 1,
45    \     'end_lnum': 1,
46    \     'col': 8,
47    \     'end_col': 12,
48    \     'type': 'W',
49    \     'code': 'L010',
50    \     'text': 'Keywords must be consistently upper case.',
51    \   },
52    \   {
53    \     'filename': 'schema.sql',
54    \     'lnum': 13,
55    \     'end_lnum': 13,
56    \     'col': 2,
57    \     'end_col': 20,
58    \     'type': 'W',
59    \     'code': 'L003',
60    \     'text': 'Expected 1 indentation, found 0 [compared to line 12]',
61    \   },
62    \   {
63    \     'filename': 'schema.sql',
64    \     'lnum': 16,
65    \     'end_lnum': 16,
66    \     'col': 1,
67    \     'end_col': 5,
68    \     'type': 'W',
69    \     'code': 'L009',
70    \     'text': 'Files must end with a single trailing newline.',
71    \   },
72    \ ],
73    \ ale_linters#sql#sqlfluff#Handle(bufnr(''), [3, 0, 0], [
74    \    '[{"filepath": "schema.sql", "violations": [{"start_line_no": 1, "end_line_no":1, "start_line_pos": 8, "end_line_pos":12, "code": "L010", "description": "Keywords must be consistently upper case."}, {"start_line_no": 13, "end_line_no":13, "start_line_pos": 2, "end_line_pos":20, "code": "L003", "description": "Expected 1 indentation, found 0 [compared to line 12]"}, {"start_line_no": 16, "end_line_no":16, "start_line_pos": 1, "end_line_pos":5, "code": "L009", "description": "Files must end with a single trailing newline."}]}]',
75    \ ])