aboutsummaryrefslogtreecommitdiff
path: root/test/functional/plugin/health_spec.lua
diff options
context:
space:
mode:
authorTJ DeVries <devries.timothyj@gmail.com>2016-06-16 17:01:47 -0400
committerJustin M. Keyes <justinkz@gmail.com>2016-08-21 21:25:33 -0400
commit2cc523c3afd3c98e80499409182ca96708d996f4 (patch)
treefa422a0b8b4522f605f296ff8adf1c4efc54072c /test/functional/plugin/health_spec.lua
parenta26d52ea328e64ab08dae369e5a7c551bb05abf7 (diff)
downloadrneovim-2cc523c3afd3c98e80499409182ca96708d996f4.tar.gz
rneovim-2cc523c3afd3c98e80499409182ca96708d996f4.tar.bz2
rneovim-2cc523c3afd3c98e80499409182ca96708d996f4.zip
CheckHealth
- Use execute() instead of redir - Fixed logic on suboptimal pyenv/virtualenv checks. - Move system calls from strings to lists. Fixes #5218 - Add highlighting - Automatically discover health checkers - Add tests Helped-by: Shougo Matsushita <Shougo.Matsu@gmail.com> Helped-by: Tommy Allen <tommy@esdf.io> Closes #4932
Diffstat (limited to 'test/functional/plugin/health_spec.lua')
-rw-r--r--test/functional/plugin/health_spec.lua58
1 files changed, 58 insertions, 0 deletions
diff --git a/test/functional/plugin/health_spec.lua b/test/functional/plugin/health_spec.lua
new file mode 100644
index 0000000000..972cabd662
--- /dev/null
+++ b/test/functional/plugin/health_spec.lua
@@ -0,0 +1,58 @@
+local helpers = require('test.functional.helpers')(after_each)
+local plugin_helpers = require('test.functional.plugin.helpers')
+
+describe('health.vim', function()
+ before_each(function()
+ plugin_helpers.reset()
+ end)
+
+ it('should echo the results when using the basic functions', function()
+ helpers.execute("call health#report_start('Foo')")
+ local report = helpers.redir_exec([[call health#report_start('Check Bar')]])
+ .. helpers.redir_exec([[call health#report_ok('Bar status')]])
+ .. helpers.redir_exec([[call health#report_ok('Other Bar status')]])
+ .. helpers.redir_exec([[call health#report_warn('Zub')]])
+ .. helpers.redir_exec([[call health#report_start('Baz')]])
+ .. helpers.redir_exec([[call health#report_warn('Zim', ['suggestion 1', 'suggestion 2'])]])
+
+ local expected_contents = {
+ 'Checking: Check Bar',
+ 'SUCCESS: Bar status',
+ 'WARNING: Zub',
+ 'SUGGESTIONS:',
+ '- suggestion 1',
+ '- suggestion 2'
+ }
+
+ for _, content in ipairs(expected_contents) do
+ assert(string.find(report, content))
+ end
+ end)
+
+
+ describe('CheckHealth', function()
+ -- Run the health check and store important results
+ -- Run it here because it may take awhile to complete, depending on the system
+ helpers.execute([[CheckHealth!]])
+ local report = helpers.curbuf_contents()
+ local health_checkers = helpers.redir_exec("echo g:health_checkers")
+
+ it('should find the default checker upon execution', function()
+ assert(string.find(health_checkers, "'health#nvim#check': v:true"))
+ end)
+
+ it('should alert the user that health#nvim#check is running', function()
+ assert(string.find(report, '# Checking health'))
+ assert(string.find(report, 'Checker health#nvim#check says:'))
+ assert(string.find(report, 'Checking:'))
+ end)
+ end)
+
+ it('should allow users to disable checkers', function()
+ helpers.execute("call health#disable_checker('health#nvim#check')")
+ helpers.execute("CheckHealth!")
+ local health_checkers = helpers.redir_exec("echo g:health_checkers")
+
+ assert(string.find(health_checkers, "'health#nvim#check': v:false"))
+ end)
+end)