aboutsummaryrefslogtreecommitdiff
path: root/test/functional/api/autocmd_spec.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2023-02-14 05:19:04 -0500
committerGitHub <noreply@github.com>2023-02-14 02:19:04 -0800
commit46a87a5d2bac598fed0870f0d3c926087f95d30f (patch)
tree500dba055ff89fcc0610e7a497d7a4471bff04f1 /test/functional/api/autocmd_spec.lua
parent53968082675cd3b8d1809e53a47c0311b7347ef9 (diff)
downloadrneovim-46a87a5d2bac598fed0870f0d3c926087f95d30f.tar.gz
rneovim-46a87a5d2bac598fed0870f0d3c926087f95d30f.tar.bz2
rneovim-46a87a5d2bac598fed0870f0d3c926087f95d30f.zip
refactor(api): VALIDATE macros #22187
Problem: - API validation involves too much boilerplate. - API validation errors are not consistently worded. Solution: Introduce some macros. Currently these are clumsy, but they at least help with consistency and avoid some nesting.
Diffstat (limited to 'test/functional/api/autocmd_spec.lua')
-rw-r--r--test/functional/api/autocmd_spec.lua18
1 files changed, 9 insertions, 9 deletions
diff --git a/test/functional/api/autocmd_spec.lua b/test/functional/api/autocmd_spec.lua
index 22a1311ee9..56b0a4d9b2 100644
--- a/test/functional/api/autocmd_spec.lua
+++ b/test/functional/api/autocmd_spec.lua
@@ -21,7 +21,7 @@ describe('autocmd api', function()
callback = "NotAllowed",
})
- eq("specify either 'callback' or 'command', not both", rv)
+ eq("Cannot use both 'callback' and 'command'", rv)
end)
it('doesnt leak when you use ++once', function()
@@ -66,7 +66,7 @@ describe('autocmd api', function()
pattern = "*.py",
})
- eq("cannot pass both: 'pattern' and 'buffer' for the same autocmd", rv)
+ eq("Cannot use both 'pattern' and 'buffer' for the same autocmd", rv)
end)
it('does not allow passing invalid buffers', function()
@@ -407,8 +407,8 @@ describe('autocmd api', function()
pattern = "<buffer=2>",
}}, aus)
- eq("Invalid value for 'buffer': must be an integer or array of integers", pcall_err(meths.get_autocmds, { event = "InsertEnter", buffer = "foo" }))
- eq("Invalid value for 'buffer': must be an integer", pcall_err(meths.get_autocmds, { event = "InsertEnter", buffer = { "foo", 42 } }))
+ eq("Invalid buffer: expected Integer or Array, got String", pcall_err(meths.get_autocmds, { event = "InsertEnter", buffer = "foo" }))
+ eq("Invalid buffer: expected Integer, got String", pcall_err(meths.get_autocmds, { event = "InsertEnter", buffer = { "foo", 42 } }))
eq("Invalid buffer id: 42", pcall_err(meths.get_autocmds, { event = "InsertEnter", buffer = { 42 } }))
local bufs = {}
@@ -416,7 +416,7 @@ describe('autocmd api', function()
table.insert(bufs, meths.create_buf(true, false))
end
- eq("Too many buffers. Please limit yourself to 256 or fewer", pcall_err(meths.get_autocmds, { event = "InsertEnter", buffer = bufs }))
+ eq("Too many buffers (maximum of 256)", pcall_err(meths.get_autocmds, { event = "InsertEnter", buffer = bufs }))
end)
it('should return autocmds when group is specified by id', function()
@@ -578,7 +578,7 @@ describe('autocmd api', function()
]], {}))
eq(false, success)
- matches('invalid augroup: NotDefined', code)
+ matches("Invalid group: 'NotDefined'", code)
end)
it('raises error for undefined augroup id', function()
@@ -596,7 +596,7 @@ describe('autocmd api', function()
]], {}))
eq(false, success)
- matches('invalid augroup: 1', code)
+ matches('Invalid group: 1', code)
end)
it('raises error for invalid group type', function()
@@ -611,7 +611,7 @@ describe('autocmd api', function()
]], {}))
eq(false, success)
- matches("'group' must be a string or an integer", code)
+ matches("Invalid group: expected String or Integer, got Boolean", code)
end)
it('raises error for invalid pattern array', function()
@@ -625,7 +625,7 @@ describe('autocmd api', function()
]], {}))
eq(false, success)
- matches("All entries in 'pattern' must be strings", code)
+ matches("Invalid 'pattern' item type: expected String, got Array", code)
end)
end)