diff options
Diffstat (limited to 'test/functional/plugin/health_spec.lua')
-rw-r--r-- | test/functional/plugin/health_spec.lua | 88 |
1 files changed, 75 insertions, 13 deletions
diff --git a/test/functional/plugin/health_spec.lua b/test/functional/plugin/health_spec.lua index 52dc008707..8ee0f258d0 100644 --- a/test/functional/plugin/health_spec.lua +++ b/test/functional/plugin/health_spec.lua @@ -1,6 +1,38 @@ local helpers = require('test.functional.helpers')(after_each) +local Screen = require('test.functional.ui.screen') local plugin_helpers = require('test.functional.plugin.helpers') +local clear = helpers.clear +local curbuf_contents = helpers.curbuf_contents +local command = helpers.command +local eq = helpers.eq + +describe(':checkhealth', function() + it("detects invalid $VIMRUNTIME", function() + clear({ + env={ VIMRUNTIME='bogus', }, + }) + local status, err = pcall(command, 'checkhealth') + eq(false, status) + eq('Invalid $VIMRUNTIME: bogus', string.match(err, 'Invalid.*')) + end) + it("detects invalid 'runtimepath'", function() + clear() + command('set runtimepath=bogus') + local status, err = pcall(command, 'checkhealth') + eq(false, status) + eq("Invalid 'runtimepath'", string.match(err, 'Invalid.*')) + end) + it("detects invalid $VIM", function() + clear() + -- Do this after startup, otherwise it just breaks $VIMRUNTIME. + command("let $VIM='zub'") + command("checkhealth nvim") + eq("ERROR: $VIM is invalid: zub", + string.match(curbuf_contents(), "ERROR: $VIM .* zub")) + end) +end) + describe('health.vim', function() before_each(function() plugin_helpers.reset() @@ -8,10 +40,10 @@ describe('health.vim', function() -- health#broken#check() -- health#success1#check() -- health#success2#check() - helpers.execute("set runtimepath+=test/functional/fixtures") + command("set runtimepath+=test/functional/fixtures") end) - it("reports", function() + it("health#report_*()", function() helpers.source([[ let g:health_report = execute([ \ "call health#report_start('Check Bar')", @@ -28,53 +60,83 @@ describe('health.vim', function() ## Check Bar - - SUCCESS: Bar status - - SUCCESS: Other Bar status + - OK: Bar status + - OK: Other Bar status - WARNING: Zub ## Baz - WARNING: Zim - - SUGGESTIONS: + - ADVICE: - suggestion 1 - suggestion 2]]), result) end) - describe(":CheckHealth", function() + describe(":checkhealth", function() it("concatenates multiple reports", function() - helpers.execute("CheckHealth success1 success2") + command("checkhealth success1 success2") helpers.expect([[ health#success1#check ======================================================================== ## report 1 - - SUCCESS: everything is fine + - OK: everything is fine ## report 2 - - SUCCESS: nothing to see here + - OK: nothing to see here health#success2#check ======================================================================== ## another 1 - - SUCCESS: ok + - OK: ok ]]) end) it("gracefully handles broken healthcheck", function() - helpers.execute("CheckHealth broken") + command("checkhealth broken") helpers.expect([[ health#broken#check ======================================================================== - ERROR: Failed to run healthcheck for "broken" plugin. Exception: - function health#check[20]..health#broken#check, line 1 + function health#check[21]..health#broken#check, line 1 caused an error ]]) end) + it("highlights OK, ERROR", function() + local screen = Screen.new(72, 10) + screen:attach() + screen:set_default_attr_ids({ + Ok = { foreground = Screen.colors.Grey3, background = 6291200 }, + Error = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, + }) + screen:set_default_attr_ignore({ + Heading = { bold=true, foreground=Screen.colors.Magenta }, + Heading2 = { foreground = Screen.colors.SlateBlue }, + Bar = { foreground=Screen.colors.Purple }, + Bullet = { bold=true, foreground=Screen.colors.Brown }, + }) + command("checkhealth foo success1") + command("1tabclose") + command("set laststatus=0") + screen:expect([[ + ^ | + health#foo#check | + ========================================================================| + - {Error:ERROR:} No healthcheck found for "foo" plugin. | + | + health#success1#check | + ========================================================================| + ## report 1 | + - {Ok:OK:} everything is fine | + | + ]]) + end) + it("gracefully handles invalid healthcheck", function() - helpers.execute("CheckHealth non_existent_healthcheck") + command("checkhealth non_existent_healthcheck") helpers.expect([[ health#non_existent_healthcheck#check |