diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-03-30 09:29:21 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-30 09:29:21 +0800 |
commit | 35239e977f53c25016b57729cada612aa53e11d4 (patch) | |
tree | 45e24edd39b7b80199d4a2b510add5c57f4148a8 /test/functional/core | |
parent | 19d63563e1cceabbf8603d0abb2e88fae5bd3626 (diff) | |
download | rneovim-35239e977f53c25016b57729cada612aa53e11d4.tar.gz rneovim-35239e977f53c25016b57729cada612aa53e11d4.tar.bz2 rneovim-35239e977f53c25016b57729cada612aa53e11d4.zip |
test: use matches(...) instead of ok(string.find(...)) (#28111)
Diffstat (limited to 'test/functional/core')
-rw-r--r-- | test/functional/core/channels_spec.lua | 3 | ||||
-rw-r--r-- | test/functional/core/job_spec.lua | 9 |
2 files changed, 5 insertions, 7 deletions
diff --git a/test/functional/core/channels_spec.lua b/test/functional/core/channels_spec.lua index 56a2f5a571..0ab885e02f 100644 --- a/test/functional/core/channels_spec.lua +++ b/test/functional/core/channels_spec.lua @@ -2,6 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local clear, eq, eval, next_msg, ok, source = helpers.clear, helpers.eq, helpers.eval, helpers.next_msg, helpers.ok, helpers.source local command, fn, api = helpers.command, helpers.fn, helpers.api +local matches = helpers.matches local sleep = vim.uv.sleep local spawn, nvim_argv = helpers.spawn, helpers.nvim_argv local get_session, set_session = helpers.get_session, helpers.set_session @@ -277,7 +278,7 @@ describe('channels', function() local _, err = pcall(command, "call rpcrequest(id, 'nvim_command', 'call chanclose(v:stderr, \"stdin\")')") - ok(string.find(err, 'E906: invalid stream for channel') ~= nil) + matches('E906: invalid stream for channel', err) eq(1, eval("rpcrequest(id, 'nvim_eval', 'chanclose(v:stderr, \"stderr\")')")) eq({ 'notification', 'stderr', { 3, { '' } } }, next_msg()) diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua index 9e7f1faa47..b7e9af99ac 100644 --- a/test/functional/core/job_spec.lua +++ b/test/functional/core/job_spec.lua @@ -73,7 +73,7 @@ describe('jobs', function() command("let j = jobstart('env', g:job_opts)") end end) - ok(string.find(err, 'E475: Invalid argument: env') ~= nil) + matches('E475: Invalid argument: env', err) end) it('append environment #env', function() @@ -227,7 +227,7 @@ describe('jobs', function() command("let j = jobstart('pwd', g:job_opts)") end end) - ok(string.find(err, 'E475: Invalid argument: expected valid directory$') ~= nil) + matches('E475: Invalid argument: expected valid directory$', err) end) it('error on non-executable `cwd`', function() @@ -980,10 +980,7 @@ describe('jobs', function() command('let g:job_opts.pty = v:true') command('let g:job_opts.rpc = v:true') local _, err = pcall(command, "let j = jobstart(['cat', '-'], g:job_opts)") - ok( - string.find(err, "E475: Invalid argument: job cannot have both 'pty' and 'rpc' options set") - ~= nil - ) + matches("E475: Invalid argument: job cannot have both 'pty' and 'rpc' options set", err) end) it('does not crash when repeatedly failing to start shell', function() |