summaryrefslogtreecommitdiff
path: root/test/fixers
diff options
context:
space:
mode:
authorbosr <bosr@users.noreply.github.com>2021-04-07 12:34:34 +0200
committerGitHub <noreply@github.com>2021-04-07 19:34:34 +0900
commitf0887d3e6178482255f11aa378124aef3699245f (patch)
treece9b0300de08ab7220ab63ed4e857da876367f9f /test/fixers
parent06f57ca9733aab6e6b67015917fdfd4bf1c70c48 (diff)
downloadale-f0887d3e6178482255f11aa378124aef3699245f.zip
apple-swift-format: linter and fixer with config swiftpm support (#3671)
Diffstat (limited to 'test/fixers')
-rw-r--r--test/fixers/test_appleswiftformat_fixer_callback.vader47
1 files changed, 47 insertions, 0 deletions
diff --git a/test/fixers/test_appleswiftformat_fixer_callback.vader b/test/fixers/test_appleswiftformat_fixer_callback.vader
new file mode 100644
index 00000000..72465f4f
--- /dev/null
+++ b/test/fixers/test_appleswiftformat_fixer_callback.vader
@@ -0,0 +1,47 @@
+Before:
+ call ale#assert#SetUpFixerTest('swift', 'apple-swift-format')
+
+After:
+ call ale#assert#TearDownFixerTest()
+
+Execute(The swiftformat callback should return the correct default values):
+ call ale#test#SetFilename('../test-files/swift/dummy.swift')
+ let g:ale_swift_appleswiftformat_executable = 'xxxinvalid'
+ let g:ale_swift_appleswiftformat_use_swiftpm = 0
+
+ AssertEqual
+ \ {
+ \ 'read_temporary_file': 1,
+ \ 'command': ale#Escape(g:ale_swift_appleswiftformat_executable)
+ \ . ' format --in-place %t',
+ \ },
+ \ ale#fixers#appleswiftformat#Fix(bufnr(''))
+
+Execute(The swiftformat callback should return the correct default values and located configuration):
+ call ale#test#SetDirectory('/testplugin/test/test-files/swift/swift-package-project-with-config')
+ call ale#test#SetFilename('src/folder/dummy.swift')
+
+ let g:ale_swift_appleswiftformat_executable = 'xxxinvalid'
+ let g:ale_swift_appleswiftformat_use_swiftpm = 0
+
+ AssertEqual
+ \ {
+ \ 'read_temporary_file': 1,
+ \ 'command': ale#Escape(g:ale_swift_appleswiftformat_executable)
+ \ . ' format --in-place %t --configuration ' . glob(g:dir . '/.swift-format'),
+ \ },
+ \ ale#fixers#appleswiftformat#Fix(bufnr(''))
+
+ call ale#test#RestoreDirectory()
+
+Execute(The swiftformat callback should use swiftpm is use_swiftpm is set to 1):
+ call ale#test#SetFilename('../test-files/swift/swift-package-project/src/folder/dummy.swift')
+ let g:ale_swift_appleswiftformat_use_swiftpm = 1
+
+ AssertEqual
+ \ {
+ \ 'read_temporary_file': 1,
+ \ 'command': ale#Escape('swift')
+ \ . ' run swift-format format --in-place %t',
+ \ },
+ \ ale#fixers#appleswiftformat#Fix(bufnr(''))