aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2024-02-12 05:50:39 -0800
committerGitHub <noreply@github.com>2024-02-12 05:50:39 -0800
commit0185152802d4a84258a9a04c1d86a7e27d37d721 (patch)
tree3880293029a66a8a009fff2f3489849c247c36db
parent210ec3b7a94c64263703087163a957567ddf4224 (diff)
downloadrneovim-0185152802d4a84258a9a04c1d86a7e27d37d721.tar.gz
rneovim-0185152802d4a84258a9a04c1d86a7e27d37d721.tar.bz2
rneovim-0185152802d4a84258a9a04c1d86a7e27d37d721.zip
refactor(tests): get channel id via nvim_get_chan_info #27441
Minor "best practices" nudge.
-rw-r--r--test/functional/api/buffer_updates_spec.lua14
-rw-r--r--test/functional/api/server_notifications_spec.lua2
-rw-r--r--test/functional/api/server_requests_spec.lua14
-rw-r--r--test/functional/autocmd/cmdline_spec.lua2
-rw-r--r--test/functional/core/exit_spec.lua2
-rw-r--r--test/functional/core/job_spec.lua2
-rw-r--r--test/functional/ex_cmds/dict_notifications_spec.lua2
-rw-r--r--test/functional/lua/vim_spec.lua2
-rw-r--r--test/functional/provider/define_spec.lua2
-rw-r--r--test/functional/vimscript/wait_spec.lua2
10 files changed, 22 insertions, 22 deletions
diff --git a/test/functional/api/buffer_updates_spec.lua b/test/functional/api/buffer_updates_spec.lua
index d68c60e54c..262ca40e28 100644
--- a/test/functional/api/buffer_updates_spec.lua
+++ b/test/functional/api/buffer_updates_spec.lua
@@ -482,7 +482,7 @@ describe('API: buffer events:', function()
end)
it('does not get confused if enabled/disabled many times', function()
- local channel = api.nvim_get_api_info()[1]
+ local channel = api.nvim_get_chan_info(0).id
local b, tick = editoriginal(false)
-- Enable buffer events many times.
@@ -564,7 +564,7 @@ describe('API: buffer events:', function()
-- make sure there are no other pending nvim_buf_lines_event messages going to
-- channel 1
- local channel1 = request(1, 'nvim_get_api_info')[1]
+ local channel1 = request(1, 'nvim_get_chan_info', 0).id
eval('rpcnotify(' .. channel1 .. ', "Hello")')
wantn(1, 'Hello', {})
@@ -576,14 +576,14 @@ describe('API: buffer events:', function()
-- make sure there are no other pending nvim_buf_lines_event messages going to
-- channel 1
- channel1 = request(1, 'nvim_get_api_info')[1]
+ channel1 = request(1, 'nvim_get_chan_info', 0).id
eval('rpcnotify(' .. channel1 .. ', "Hello Again")')
wantn(1, 'Hello Again', {})
end)
it('works with :diffput and :diffget', function()
local b1, tick1 = editoriginal(true, { 'AAA', 'BBB' })
- local channel = api.nvim_get_api_info()[1]
+ local channel = api.nvim_get_chan_info(0).id
command('diffthis')
command('rightbelow vsplit')
local b2, tick2 = open(true, { 'BBB', 'CCC' })
@@ -700,7 +700,7 @@ describe('API: buffer events:', function()
it('detaches if the buffer is closed', function()
local b, tick = editoriginal(true, { 'AAA' })
- local channel = api.nvim_get_api_info()[1]
+ local channel = api.nvim_get_chan_info(0).id
-- Test that buffer events are working.
command('normal! x')
@@ -739,7 +739,7 @@ describe('API: buffer events:', function()
it(':enew! does not detach hidden buffer', function()
local b, tick = editoriginal(true, { 'AAA', 'BBB' })
- local channel = api.nvim_get_api_info()[1]
+ local channel = api.nvim_get_chan_info(0).id
command('set undoreload=1 hidden')
command('normal! x')
@@ -753,7 +753,7 @@ describe('API: buffer events:', function()
it('stays attached if the buffer is hidden', function()
local b, tick = editoriginal(true, { 'AAA' })
- local channel = api.nvim_get_api_info()[1]
+ local channel = api.nvim_get_chan_info(0).id
-- Test that buffer events are working.
command('normal! x')
diff --git a/test/functional/api/server_notifications_spec.lua b/test/functional/api/server_notifications_spec.lua
index f6058b14ee..d1608a951c 100644
--- a/test/functional/api/server_notifications_spec.lua
+++ b/test/functional/api/server_notifications_spec.lua
@@ -14,7 +14,7 @@ describe('notify', function()
before_each(function()
clear()
- channel = api.nvim_get_api_info()[1]
+ channel = api.nvim_get_chan_info(0).id
end)
after_each(function()
diff --git a/test/functional/api/server_requests_spec.lua b/test/functional/api/server_requests_spec.lua
index 5e508e7513..298dbac217 100644
--- a/test/functional/api/server_requests_spec.lua
+++ b/test/functional/api/server_requests_spec.lua
@@ -18,18 +18,18 @@ describe('server -> client', function()
before_each(function()
clear()
- cid = api.nvim_get_api_info()[1]
+ cid = api.nvim_get_chan_info(0).id
end)
it('handles unexpected closed stream while preparing RPC response', function()
source([[
let g:_nvim_args = [v:progpath, '--embed', '--headless', '-n', '-u', 'NONE', '-i', 'NONE', ]
let ch1 = jobstart(g:_nvim_args, {'rpc': v:true})
- let child1_ch = rpcrequest(ch1, "nvim_get_api_info")[0]
+ let child1_ch = rpcrequest(ch1, "nvim_get_chan_info", 0).id
call rpcnotify(ch1, 'nvim_eval', 'rpcrequest('.child1_ch.', "nvim_get_api_info")')
let ch2 = jobstart(g:_nvim_args, {'rpc': v:true})
- let child2_ch = rpcrequest(ch2, "nvim_get_api_info")[0]
+ let child2_ch = rpcrequest(ch2, "nvim_get_chan_info", 0).id
call rpcnotify(ch2, 'nvim_eval', 'rpcrequest('.child2_ch.', "nvim_get_api_info")')
call jobstop(ch1)
@@ -231,7 +231,7 @@ describe('server -> client', function()
describe('jobstart()', function()
local jobid
before_each(function()
- local channel = api.nvim_get_api_info()[1]
+ local channel = api.nvim_get_chan_info(0).id
api.nvim_set_var('channel', channel)
source([[
function! s:OnEvent(id, data, event)
@@ -292,7 +292,7 @@ describe('server -> client', function()
ok(id > 0)
fn.rpcrequest(id, 'nvim_set_current_line', 'hello')
- local client_id = fn.rpcrequest(id, 'nvim_get_api_info')[1]
+ local client_id = fn.rpcrequest(id, 'nvim_get_chan_info', 0).id
set_session(server)
eq(serverpid, fn.getpid())
@@ -300,7 +300,7 @@ describe('server -> client', function()
-- method calls work both ways
fn.rpcrequest(client_id, 'nvim_set_current_line', 'howdy!')
- eq(id, fn.rpcrequest(client_id, 'nvim_get_api_info')[1])
+ eq(id, fn.rpcrequest(client_id, 'nvim_get_chan_info', 0).id)
set_session(client)
eq(clientpid, fn.getpid())
@@ -378,7 +378,7 @@ describe('server -> client', function()
eq('hello', api.nvim_get_current_line())
eq(serverpid, fn.rpcrequest(id, 'nvim_eval', 'getpid()'))
- eq(id, fn.rpcrequest(id, 'nvim_get_api_info')[1])
+ eq(id, fn.rpcrequest(id, 'nvim_get_chan_info', 0).id)
end)
end)
end)
diff --git a/test/functional/autocmd/cmdline_spec.lua b/test/functional/autocmd/cmdline_spec.lua
index 5a5b16b438..7428456656 100644
--- a/test/functional/autocmd/cmdline_spec.lua
+++ b/test/functional/autocmd/cmdline_spec.lua
@@ -14,7 +14,7 @@ describe('cmdline autocommands', function()
local channel
before_each(function()
clear()
- channel = api.nvim_get_api_info()[1]
+ channel = api.nvim_get_chan_info(0).id
api.nvim_set_var('channel', channel)
command("autocmd CmdlineEnter * call rpcnotify(g:channel, 'CmdlineEnter', v:event)")
command("autocmd CmdlineLeave * call rpcnotify(g:channel, 'CmdlineLeave', v:event)")
diff --git a/test/functional/core/exit_spec.lua b/test/functional/core/exit_spec.lua
index b74ebb2367..d9e3cc3f31 100644
--- a/test/functional/core/exit_spec.lua
+++ b/test/functional/core/exit_spec.lua
@@ -18,7 +18,7 @@ describe('v:exiting', function()
before_each(function()
helpers.clear()
- cid = helpers.api.nvim_get_api_info()[1]
+ cid = helpers.api.nvim_get_chan_info(0).id
end)
it('defaults to v:null', function()
diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua
index c6885d0b7c..318730fbb1 100644
--- a/test/functional/core/job_spec.lua
+++ b/test/functional/core/job_spec.lua
@@ -42,7 +42,7 @@ describe('jobs', function()
before_each(function()
clear()
- channel = api.nvim_get_api_info()[1]
+ channel = api.nvim_get_chan_info(0).id
api.nvim_set_var('channel', channel)
source([[
function! Normalize(data) abort
diff --git a/test/functional/ex_cmds/dict_notifications_spec.lua b/test/functional/ex_cmds/dict_notifications_spec.lua
index 15fbb750f6..fc7714d16b 100644
--- a/test/functional/ex_cmds/dict_notifications_spec.lua
+++ b/test/functional/ex_cmds/dict_notifications_spec.lua
@@ -14,7 +14,7 @@ describe('Vimscript dictionary notifications', function()
before_each(function()
clear()
- channel = api.nvim_get_api_info()[1]
+ channel = api.nvim_get_chan_info(0).id
api.nvim_set_var('channel', channel)
end)
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua
index 10a2437ba2..c7490756d4 100644
--- a/test/functional/lua/vim_spec.lua
+++ b/test/functional/lua/vim_spec.lua
@@ -3363,7 +3363,7 @@ describe('lua stdlib', function()
describe('returns -2 when interrupted', function()
before_each(function()
- local channel = api.nvim_get_api_info()[1]
+ local channel = api.nvim_get_chan_info(0).id
api.nvim_set_var('channel', channel)
end)
diff --git a/test/functional/provider/define_spec.lua b/test/functional/provider/define_spec.lua
index a1109935d2..657f1a0d8a 100644
--- a/test/functional/provider/define_spec.lua
+++ b/test/functional/provider/define_spec.lua
@@ -362,7 +362,7 @@ local function function_specs_for(fn, sync, first_arg_factory, init)
end
local function channel()
- return api.nvim_get_api_info()[1]
+ return api.nvim_get_chan_info(0).id
end
local function host()
diff --git a/test/functional/vimscript/wait_spec.lua b/test/functional/vimscript/wait_spec.lua
index 4ee3b183b3..50cdb2cfb4 100644
--- a/test/functional/vimscript/wait_spec.lua
+++ b/test/functional/vimscript/wait_spec.lua
@@ -13,7 +13,7 @@ local pcall_err = helpers.pcall_err
before_each(function()
clear()
- local channel = api.nvim_get_api_info()[1]
+ local channel = api.nvim_get_chan_info(0).id
api.nvim_set_var('channel', channel)
end)