API: validation: mention invalid method name (#8489)

This commit is contained in:
Justin M. Keyes
2018-06-07 10:56:44 +02:00
committed by GitHub
parent 5a82afa17a
commit 3abf17ae88
7 changed files with 37 additions and 11 deletions

View File

@@ -31,7 +31,7 @@ end
local function on_notification(event, args)
if event == 'ping' and #args == 0 then
session:notify("vim_eval", "rpcnotify(g:channel, 'pong')")
session:notify("nvim_eval", "rpcnotify(g:channel, 'pong')")
end
end

View File

@@ -222,7 +222,7 @@ describe('server -> client', function()
end)
it('returns an error if the request failed', function()
expect_err('Vim:Invalid method name',
expect_err('Vim:Invalid method: does%-not%-exist',
eval, "rpcrequest(vim, 'does-not-exist')")
end)
end)

View File

@@ -20,9 +20,20 @@ local format_string = global_helpers.format_string
local intchar2lua = global_helpers.intchar2lua
local mergedicts_copy = global_helpers.mergedicts_copy
describe('api', function()
describe('API', function()
before_each(clear)
it('validates requests', function()
expect_err('Invalid method: bogus',
request, 'bogus')
expect_err('Invalid method: … の り 。…',
request, '… の り 。…')
expect_err('Invalid method: <empty>',
request, '')
expect_err("can't serialize object",
request, nil)
end)
describe('nvim_command', function()
it('works', function()
local fname = helpers.tmpname()
@@ -924,7 +935,7 @@ describe('api', function()
{'i_am_not_a_method', {'xx'}},
{'nvim_set_var', {'avar', 10}},
}
eq({{}, {0, error_types.Exception.id, 'Invalid method name'}},
eq({{}, {0, error_types.Exception.id, 'Invalid method: i_am_not_a_method'}},
meths.call_atomic(req))
eq(5, meths.get_var('avar'))
end)