test(lua/secure_spec): avoid magic number (#33700)

Avoid magic number in skipping condition by moving the expected message
to a variable.

(cherry picked from commit c489b5a3e3)
This commit is contained in:
zeertzjq
2025-04-29 09:44:54 +08:00
committed by github-actions[bot]
parent 0ed06d7271
commit c753e70abb

View File

@@ -55,7 +55,8 @@ describe('vim.secure', function()
}) })
local cwd = fn.getcwd() local cwd = fn.getcwd()
if #cwd + 23 > 500 then local msg = cwd .. pathsep .. 'Xfile is not trusted.'
if #msg >= screen._width then
pending('path too long') pending('path too long')
return return
end end
@@ -67,7 +68,7 @@ describe('vim.secure', function()
{1:~{MATCH: +}}|*3 {1:~{MATCH: +}}|*3
{2:{MATCH: +}}| {2:{MATCH: +}}|
:lua vim.secure.read('Xfile'){MATCH: +}| :lua vim.secure.read('Xfile'){MATCH: +}|
{3:]] .. cwd .. pathsep .. [[Xfile is not trusted.}{MATCH: +}| {3:]] .. msg .. [[}{MATCH: +}|
{3:[i]gnore, (v)iew, (d)eny, (a)llow: }^{MATCH: +}| {3:[i]gnore, (v)iew, (d)eny, (a)llow: }^{MATCH: +}|
]]) ]])
feed('d') feed('d')
@@ -89,7 +90,7 @@ describe('vim.secure', function()
{1:~{MATCH: +}}|*3 {1:~{MATCH: +}}|*3
{2:{MATCH: +}}| {2:{MATCH: +}}|
:lua vim.secure.read('Xfile'){MATCH: +}| :lua vim.secure.read('Xfile'){MATCH: +}|
{3:]] .. cwd .. pathsep .. [[Xfile is not trusted.}{MATCH: +}| {3:]] .. msg .. [[}{MATCH: +}|
{3:[i]gnore, (v)iew, (d)eny, (a)llow: }^{MATCH: +}| {3:[i]gnore, (v)iew, (d)eny, (a)llow: }^{MATCH: +}|
]]) ]])
feed('a') feed('a')
@@ -112,7 +113,7 @@ describe('vim.secure', function()
{1:~{MATCH: +}}|*3 {1:~{MATCH: +}}|*3
{2:{MATCH: +}}| {2:{MATCH: +}}|
:lua vim.secure.read('Xfile'){MATCH: +}| :lua vim.secure.read('Xfile'){MATCH: +}|
{3:]] .. cwd .. pathsep .. [[Xfile is not trusted.}{MATCH: +}| {3:]] .. msg .. [[}{MATCH: +}|
{3:[i]gnore, (v)iew, (d)eny, (a)llow: }^{MATCH: +}| {3:[i]gnore, (v)iew, (d)eny, (a)llow: }^{MATCH: +}|
]]) ]])
feed('i') feed('i')
@@ -131,7 +132,7 @@ describe('vim.secure', function()
{1:~{MATCH: +}}|*3 {1:~{MATCH: +}}|*3
{2:{MATCH: +}}| {2:{MATCH: +}}|
:lua vim.secure.read('Xfile'){MATCH: +}| :lua vim.secure.read('Xfile'){MATCH: +}|
{3:]] .. cwd .. pathsep .. [[Xfile is not trusted.}{MATCH: +}| {3:]] .. msg .. [[}{MATCH: +}|
{3:[i]gnore, (v)iew, (d)eny, (a)llow: }^{MATCH: +}| {3:[i]gnore, (v)iew, (d)eny, (a)llow: }^{MATCH: +}|
]]) ]])
feed('v') feed('v')