2016-06-16 14:01:47 -07:00
|
|
|
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()
|
2016-08-20 16:37:18 -07:00
|
|
|
-- Provides functions:
|
|
|
|
-- health#broken#check()
|
|
|
|
-- health#success1#check()
|
|
|
|
-- health#success2#check()
|
|
|
|
helpers.execute("set runtimepath+=test/functional/fixtures")
|
2016-06-16 14:01:47 -07:00
|
|
|
end)
|
|
|
|
|
2016-08-20 16:37:18 -07:00
|
|
|
it("reports", function()
|
|
|
|
helpers.source([[
|
|
|
|
let g:health_report = execute([
|
|
|
|
\ "call health#report_start('Check Bar')",
|
|
|
|
\ "call health#report_ok('Bar status')",
|
|
|
|
\ "call health#report_ok('Other Bar status')",
|
|
|
|
\ "call health#report_warn('Zub')",
|
|
|
|
\ "call health#report_start('Baz')",
|
|
|
|
\ "call health#report_warn('Zim', ['suggestion 1', 'suggestion 2'])"
|
|
|
|
\ ])
|
|
|
|
]])
|
|
|
|
local result = helpers.eval("g:health_report")
|
|
|
|
|
|
|
|
helpers.eq(helpers.dedent([[
|
|
|
|
|
|
|
|
|
|
|
|
## Check Bar
|
|
|
|
- SUCCESS: Bar status
|
|
|
|
- SUCCESS: Other Bar status
|
|
|
|
- WARNING: Zub
|
|
|
|
|
|
|
|
## Baz
|
|
|
|
- WARNING: Zim
|
2016-09-04 19:57:19 -07:00
|
|
|
- SUGGESTIONS:
|
|
|
|
- suggestion 1
|
|
|
|
- suggestion 2]]),
|
2016-08-20 16:37:18 -07:00
|
|
|
result)
|
2016-06-16 14:01:47 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
|
2016-08-20 16:37:18 -07:00
|
|
|
describe(":CheckHealth", function()
|
|
|
|
it("concatenates multiple reports", function()
|
|
|
|
helpers.execute("CheckHealth success1 success2")
|
|
|
|
helpers.expect([[
|
2016-09-04 19:57:19 -07:00
|
|
|
|
2016-08-20 16:37:18 -07:00
|
|
|
health#success1#check
|
2016-10-25 06:28:34 -07:00
|
|
|
========================================================================
|
2016-08-20 16:37:18 -07:00
|
|
|
## report 1
|
|
|
|
- SUCCESS: everything is fine
|
2016-06-16 14:01:47 -07:00
|
|
|
|
2016-08-20 16:37:18 -07:00
|
|
|
## report 2
|
|
|
|
- SUCCESS: nothing to see here
|
|
|
|
|
|
|
|
health#success2#check
|
2016-10-25 06:28:34 -07:00
|
|
|
========================================================================
|
2016-08-20 16:37:18 -07:00
|
|
|
## another 1
|
2016-09-04 19:57:19 -07:00
|
|
|
- SUCCESS: ok
|
|
|
|
]])
|
2016-06-16 14:01:47 -07:00
|
|
|
end)
|
|
|
|
|
2016-08-20 16:37:18 -07:00
|
|
|
it("gracefully handles broken healthcheck", function()
|
|
|
|
helpers.execute("CheckHealth broken")
|
|
|
|
helpers.expect([[
|
2016-09-04 19:57:19 -07:00
|
|
|
|
2016-08-20 16:37:18 -07:00
|
|
|
health#broken#check
|
2016-10-25 06:28:34 -07:00
|
|
|
========================================================================
|
2016-08-20 16:37:18 -07:00
|
|
|
- ERROR: Failed to run healthcheck for "broken" plugin. Exception:
|
2016-11-12 03:59:15 -07:00
|
|
|
function health#check[20]..health#broken#check, line 1
|
2016-09-04 19:57:19 -07:00
|
|
|
caused an error
|
|
|
|
]])
|
2016-08-20 16:37:18 -07:00
|
|
|
end)
|
2016-06-16 14:01:47 -07:00
|
|
|
|
2016-08-20 16:37:18 -07:00
|
|
|
it("gracefully handles invalid healthcheck", function()
|
|
|
|
helpers.execute("CheckHealth non_existent_healthcheck")
|
|
|
|
helpers.expect([[
|
2016-09-04 19:57:19 -07:00
|
|
|
|
2016-08-20 16:37:18 -07:00
|
|
|
health#non_existent_healthcheck#check
|
2016-10-25 06:28:34 -07:00
|
|
|
========================================================================
|
2016-09-04 19:57:19 -07:00
|
|
|
- ERROR: No healthcheck found for "non_existent_healthcheck" plugin.
|
|
|
|
]])
|
2016-08-20 16:37:18 -07:00
|
|
|
end)
|
2016-06-16 14:01:47 -07:00
|
|
|
end)
|
|
|
|
end)
|