summaryrefslogtreecommitdiff
path: root/test/command_callback/test_staticcheck_command_callback.vader
blob: e9628eb699e3b9a0b43172cb4c0cf2962fea4229 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Before:
  Save b:ale_go_staticcheck_options
  Save b:ale_go_staticcheck_lint_package

  let b:ale_go_staticcheck_options = ''
  let b:ale_go_staticcheck_lint_package = 0

  runtime ale_linters/go/staticcheck.vim

  call ale#test#SetDirectory('/testplugin/test/command_callback')
  call ale#test#SetFilename('test.go')

After:
  Restore

  call ale#test#RestoreDirectory()
  call ale#linter#Reset()

Execute(The staticcheck callback should return the right defaults):
  AssertEqual
  \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
  \   . 'staticcheck '
  \   . ale#Escape(expand('%' . ':t')),
  \ ale_linters#go#staticcheck#GetCommand(bufnr(''))

Execute(The staticcheck callback should use configured options):
  let b:ale_go_staticcheck_options = '-test'

  AssertEqual
  \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
  \   . 'staticcheck '
  \   . '-test ' . ale#Escape(expand('%' . ':t')),
  \ ale_linters#go#staticcheck#GetCommand(bufnr(''))

Execute(The staticcheck `lint_package` option should use the correct command):
  let b:ale_go_staticcheck_lint_package = 1

  AssertEqual
  \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
  \   . 'staticcheck .',
  \ ale_linters#go#staticcheck#GetCommand(bufnr(''))