diff options
author | Lewis Russell <lewis6991@gmail.com> | 2024-01-12 17:59:57 +0000 |
---|---|---|
committer | Lewis Russell <lewis6991@gmail.com> | 2024-01-12 18:59:14 +0000 |
commit | 795f896a5772d5e0795f86642bdf90c82efac45c (patch) | |
tree | 308f04fbee18d2ec3f00c12a8bec96b84d8907f0 /test/functional/api/server_requests_spec.lua | |
parent | 4f81f506f96f8b5bfcf00e952ceb492d3ce9dc6e (diff) | |
download | rneovim-795f896a5772d5e0795f86642bdf90c82efac45c.tar.gz rneovim-795f896a5772d5e0795f86642bdf90c82efac45c.tar.bz2 rneovim-795f896a5772d5e0795f86642bdf90c82efac45c.zip |
test: rename (meths, funcs) -> (api, fn)
Diffstat (limited to 'test/functional/api/server_requests_spec.lua')
-rw-r--r-- | test/functional/api/server_requests_spec.lua | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/test/functional/api/server_requests_spec.lua b/test/functional/api/server_requests_spec.lua index e06d32f656..5e508e7513 100644 --- a/test/functional/api/server_requests_spec.lua +++ b/test/functional/api/server_requests_spec.lua @@ -4,10 +4,10 @@ local helpers = require('test.functional.helpers')(after_each) local clear, eval = helpers.clear, helpers.eval local eq, neq, run, stop = helpers.eq, helpers.neq, helpers.run, helpers.stop -local nvim_prog, command, funcs = helpers.nvim_prog, helpers.command, helpers.funcs +local nvim_prog, command, fn = helpers.nvim_prog, helpers.command, helpers.fn local source, next_msg = helpers.source, helpers.next_msg local ok = helpers.ok -local meths = helpers.meths +local api = helpers.api local spawn, merge_args = helpers.spawn, helpers.merge_args local set_session = helpers.set_session local pcall_err = helpers.pcall_err @@ -18,7 +18,7 @@ describe('server -> client', function() before_each(function() clear() - cid = meths.nvim_get_api_info()[1] + cid = api.nvim_get_api_info()[1] end) it('handles unexpected closed stream while preparing RPC response', function() @@ -77,15 +77,15 @@ describe('server -> client', function() describe('recursive call', function() it('works', function() local function on_setup() - meths.nvim_set_var('result1', 0) - meths.nvim_set_var('result2', 0) - meths.nvim_set_var('result3', 0) - meths.nvim_set_var('result4', 0) + api.nvim_set_var('result1', 0) + api.nvim_set_var('result2', 0) + api.nvim_set_var('result3', 0) + api.nvim_set_var('result4', 0) command('let g:result1 = rpcrequest(' .. cid .. ', "rcall", 2)') - eq(4, meths.nvim_get_var('result1')) - eq(8, meths.nvim_get_var('result2')) - eq(16, meths.nvim_get_var('result3')) - eq(32, meths.nvim_get_var('result4')) + eq(4, api.nvim_get_var('result1')) + eq(8, api.nvim_get_var('result2')) + eq(16, api.nvim_get_var('result3')) + eq(32, api.nvim_get_var('result4')) stop() end @@ -113,12 +113,12 @@ describe('server -> client', function() it('does not delay notifications during pending request', function() local received = false local function on_setup() - eq('retval', funcs.rpcrequest(cid, 'doit')) + eq('retval', fn.rpcrequest(cid, 'doit')) stop() end local function on_request(method) if method == 'doit' then - funcs.rpcnotify(cid, 'headsup') + fn.rpcnotify(cid, 'headsup') eq(true, received) return 'retval' end @@ -231,8 +231,8 @@ describe('server -> client', function() describe('jobstart()', function() local jobid before_each(function() - local channel = meths.nvim_get_api_info()[1] - meths.nvim_set_var('channel', channel) + local channel = api.nvim_get_api_info()[1] + api.nvim_set_var('channel', channel) source([[ function! s:OnEvent(id, data, event) call rpcnotify(g:channel, a:event, 0, a:data) @@ -244,7 +244,7 @@ describe('server -> client', function() \ 'rpc': v:true \ } ]]) - meths.nvim_set_var('args', { + api.nvim_set_var('args', { nvim_prog, '-ll', 'test/functional/api/rpc_fixture.lua', @@ -256,7 +256,7 @@ describe('server -> client', function() end) after_each(function() - pcall(funcs.jobstop, jobid) + pcall(fn.jobstop, jobid) end) if helpers.skip(helpers.is_os('win')) then @@ -264,16 +264,16 @@ describe('server -> client', function() end it('rpc and text stderr can be combined', function() - local status, rv = pcall(funcs.rpcrequest, jobid, 'poll') + local status, rv = pcall(fn.rpcrequest, jobid, 'poll') if not status then error(string.format('missing nvim Lua module? (%s)', rv)) end eq('ok', rv) - funcs.rpcnotify(jobid, 'ping') + fn.rpcnotify(jobid, 'ping') eq({ 'notification', 'pong', {} }, next_msg()) - eq('done!', funcs.rpcrequest(jobid, 'write_stderr', 'fluff\n')) + eq('done!', fn.rpcrequest(jobid, 'write_stderr', 'fluff\n')) eq({ 'notification', 'stderr', { 0, { 'fluff', '' } } }, next_msg()) - pcall(funcs.rpcrequest, jobid, 'exit') + pcall(fn.rpcrequest, jobid, 'exit') eq({ 'notification', 'stderr', { 0, { '' } } }, next_msg()) eq({ 'notification', 'exit', { 0, 0 } }, next_msg()) end) @@ -282,29 +282,29 @@ describe('server -> client', function() describe('connecting to another (peer) nvim', function() local nvim_argv = merge_args(helpers.nvim_argv, { '--headless' }) local function connect_test(server, mode, address) - local serverpid = funcs.getpid() + local serverpid = fn.getpid() local client = spawn(nvim_argv, false, nil, true) set_session(client) - local clientpid = funcs.getpid() + local clientpid = fn.getpid() neq(serverpid, clientpid) - local id = funcs.sockconnect(mode, address, { rpc = true }) + local id = fn.sockconnect(mode, address, { rpc = true }) ok(id > 0) - funcs.rpcrequest(id, 'nvim_set_current_line', 'hello') - local client_id = funcs.rpcrequest(id, 'nvim_get_api_info')[1] + fn.rpcrequest(id, 'nvim_set_current_line', 'hello') + local client_id = fn.rpcrequest(id, 'nvim_get_api_info')[1] set_session(server) - eq(serverpid, funcs.getpid()) - eq('hello', meths.nvim_get_current_line()) + eq(serverpid, fn.getpid()) + eq('hello', api.nvim_get_current_line()) -- method calls work both ways - funcs.rpcrequest(client_id, 'nvim_set_current_line', 'howdy!') - eq(id, funcs.rpcrequest(client_id, 'nvim_get_api_info')[1]) + fn.rpcrequest(client_id, 'nvim_set_current_line', 'howdy!') + eq(id, fn.rpcrequest(client_id, 'nvim_get_api_info')[1]) set_session(client) - eq(clientpid, funcs.getpid()) - eq('howdy!', meths.nvim_get_current_line()) + eq(clientpid, fn.getpid()) + eq('howdy!', api.nvim_get_current_line()) server:close() client:close() @@ -313,7 +313,7 @@ describe('server -> client', function() it('via named pipe', function() local server = spawn(nvim_argv) set_session(server) - local address = funcs.serverlist()[1] + local address = fn.serverlist()[1] local first = string.sub(address, 1, 1) ok(first == '/' or first == '\\') connect_test(server, 'pipe', address) @@ -322,7 +322,7 @@ describe('server -> client', function() it('via ipv4 address', function() local server = spawn(nvim_argv) set_session(server) - local status, address = pcall(funcs.serverstart, '127.0.0.1:') + local status, address = pcall(fn.serverstart, '127.0.0.1:') if not status then pending('no ipv4 stack') end @@ -333,7 +333,7 @@ describe('server -> client', function() it('via ipv6 address', function() local server = spawn(nvim_argv) set_session(server) - local status, address = pcall(funcs.serverstart, '::1:') + local status, address = pcall(fn.serverstart, '::1:') if not status then pending('no ipv6 stack') end @@ -344,7 +344,7 @@ describe('server -> client', function() it('via hostname', function() local server = spawn(nvim_argv) set_session(server) - local address = funcs.serverstart('localhost:') + local address = fn.serverstart('localhost:') eq('localhost:', string.sub(address, 1, 10)) connect_test(server, 'tcp', address) end) @@ -352,12 +352,12 @@ describe('server -> client', function() it('does not crash on receiving UI events', function() local server = spawn(nvim_argv) set_session(server) - local address = funcs.serverlist()[1] + local address = fn.serverlist()[1] local client = spawn(nvim_argv, false, nil, true) set_session(client) - local id = funcs.sockconnect('pipe', address, { rpc = true }) - funcs.rpcrequest(id, 'nvim_ui_attach', 80, 24, {}) + local id = fn.sockconnect('pipe', address, { rpc = true }) + fn.rpcrequest(id, 'nvim_ui_attach', 80, 24, {}) assert_alive() server:close() @@ -367,18 +367,18 @@ describe('server -> client', function() describe('connecting to its own pipe address', function() it('does not deadlock', function() - local address = funcs.serverlist()[1] + local address = fn.serverlist()[1] local first = string.sub(address, 1, 1) ok(first == '/' or first == '\\') - local serverpid = funcs.getpid() + local serverpid = fn.getpid() - local id = funcs.sockconnect('pipe', address, { rpc = true }) + local id = fn.sockconnect('pipe', address, { rpc = true }) - funcs.rpcrequest(id, 'nvim_set_current_line', 'hello') - eq('hello', meths.nvim_get_current_line()) - eq(serverpid, funcs.rpcrequest(id, 'nvim_eval', 'getpid()')) + fn.rpcrequest(id, 'nvim_set_current_line', 'hello') + eq('hello', api.nvim_get_current_line()) + eq(serverpid, fn.rpcrequest(id, 'nvim_eval', 'getpid()')) - eq(id, funcs.rpcrequest(id, 'nvim_get_api_info')[1]) + eq(id, fn.rpcrequest(id, 'nvim_get_api_info')[1]) end) end) end) |