summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authoraliou <aliou@users.noreply.github.com>2017-10-03 19:54:35 +0200
committerw0rp <w0rp@users.noreply.github.com>2017-10-03 18:54:35 +0100
commite376f0ae44f0656021a8c8945212dc27105b34fe (patch)
tree0069e4df1b6804c221b426e6bac4193dfed77e33 /test
parent3ab414de1a9591b3c3545124329645ec4621cc60 (diff)
downloadale-e376f0ae44f0656021a8c8945212dc27105b34fe.zip
gofmt fixer for Go (#970)
Add a gofmt fixer for golang.
Diffstat (limited to 'test')
-rw-r--r--test/fixers/test_gofmt_fixer_callback.vader40
-rw-r--r--test/go_files/testfile.go0
2 files changed, 40 insertions, 0 deletions
diff --git a/test/fixers/test_gofmt_fixer_callback.vader b/test/fixers/test_gofmt_fixer_callback.vader
new file mode 100644
index 00000000..14e6e063
--- /dev/null
+++ b/test/fixers/test_gofmt_fixer_callback.vader
@@ -0,0 +1,40 @@
+Before:
+ Save g:ale_go_gofmt_executable
+ Save g:ale_go_gofmt_options
+
+ " Use an invalid global executable, so we don't match it.
+ let g:ale_go_gofmt_executable = 'xxxinvalid'
+ let g:ale_go_gofmt_options = ''
+
+ call ale#test#SetDirectory('/testplugin/test/fixers')
+
+After:
+ Restore
+
+ call ale#test#RestoreDirectory()
+
+Execute(The gofmt callback should return the correct default values):
+ call ale#test#SetFilename('../go_files/testfile.go')
+
+ AssertEqual
+ \ {
+ \ 'read_temporary_file': 1,
+ \ 'command': ale#Escape('xxxinvalid')
+ \ . ' -l -w'
+ \ . ' %t',
+ \ },
+ \ ale#fixers#gofmt#Fix(bufnr(''))
+
+Execute(The gofmt callback should include custom gofmt options):
+ let g:ale_go_gofmt_options = "-r '(a) -> a'"
+ call ale#test#SetFilename('../go_files/testfile.go')
+
+ AssertEqual
+ \ {
+ \ 'read_temporary_file': 1,
+ \ 'command': ale#Escape('xxxinvalid')
+ \ . ' -l -w'
+ \ . ' ' . g:ale_go_gofmt_options
+ \ . ' %t',
+ \ },
+ \ ale#fixers#gofmt#Fix(bufnr(''))
diff --git a/test/go_files/testfile.go b/test/go_files/testfile.go
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/go_files/testfile.go