diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2016-08-21 22:04:15 -0400 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2016-08-21 22:04:15 -0400 |
commit | b8e6f04e6952a5fb3179a6b243e0506bf979532a (patch) | |
tree | 57702cc022f34b12b873c288456bddb4db0b5134 /test | |
parent | a26d52ea328e64ab08dae369e5a7c551bb05abf7 (diff) | |
parent | 297677ecf42501d2bef45dd4f083002a0963b205 (diff) | |
download | rneovim-b8e6f04e6952a5fb3179a6b243e0506bf979532a.tar.gz rneovim-b8e6f04e6952a5fb3179a6b243e0506bf979532a.tar.bz2 rneovim-b8e6f04e6952a5fb3179a6b243e0506bf979532a.zip |
Merge #5205 'CheckHealth'
Diffstat (limited to 'test')
4 files changed, 94 insertions, 0 deletions
diff --git a/test/functional/fixtures/autoload/health/broken.vim b/test/functional/fixtures/autoload/health/broken.vim new file mode 100644 index 0000000000..a2a595b96f --- /dev/null +++ b/test/functional/fixtures/autoload/health/broken.vim @@ -0,0 +1,3 @@ +function! health#broken#check() + throw 'caused an error' +endfunction diff --git a/test/functional/fixtures/autoload/health/success1.vim b/test/functional/fixtures/autoload/health/success1.vim new file mode 100644 index 0000000000..a360347455 --- /dev/null +++ b/test/functional/fixtures/autoload/health/success1.vim @@ -0,0 +1,6 @@ +function! health#success1#check() + call health#report_start("report 1") + call health#report_ok("everything is fine") + call health#report_start("report 2") + call health#report_ok("nothing to see here") +endfunction diff --git a/test/functional/fixtures/autoload/health/success2.vim b/test/functional/fixtures/autoload/health/success2.vim new file mode 100644 index 0000000000..b742b4879d --- /dev/null +++ b/test/functional/fixtures/autoload/health/success2.vim @@ -0,0 +1,4 @@ +function! health#success2#check() + call health#report_start("another 1") + call health#report_ok("ok") +endfunction diff --git a/test/functional/plugin/health_spec.lua b/test/functional/plugin/health_spec.lua new file mode 100644 index 0000000000..a9665cd751 --- /dev/null +++ b/test/functional/plugin/health_spec.lua @@ -0,0 +1,81 @@ +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() + -- Provides functions: + -- health#broken#check() + -- health#success1#check() + -- health#success2#check() + helpers.execute("set runtimepath+=test/functional/fixtures") + end) + + 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 + - SUGGESTIONS: + - suggestion 1 + - suggestion 2]]), + result) + end) + + + describe(":CheckHealth", function() + it("concatenates multiple reports", function() + helpers.execute("CheckHealth success1 success2") + helpers.expect([[ + health#success1#check + ================================================================================ + + ## report 1 + - SUCCESS: everything is fine + + ## report 2 + - SUCCESS: nothing to see here + + health#success2#check + ================================================================================ + + ## another 1 + - SUCCESS: ok]]) + end) + + it("gracefully handles broken healthcheck", function() + helpers.execute("CheckHealth broken") + helpers.expect([[ + health#broken#check + ================================================================================ + - ERROR: Failed to run healthcheck for "broken" plugin. Exception: + caused an error]]) + end) + + it("gracefully handles invalid healthcheck", function() + helpers.execute("CheckHealth non_existent_healthcheck") + helpers.expect([[ + health#non_existent_healthcheck#check + ================================================================================ + - ERROR: No healthcheck found for "non_existent_healthcheck" plugin.]]) + end) + end) +end) |