aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ex_cmds/trust_spec.lua
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-02-18 09:27:10 +0800
committerzeertzjq <zeertzjq@outlook.com>2023-02-18 10:44:35 +0800
commit9b9f8dfcc41ceb80d3970eb58af8ee350b57dc7f (patch)
treec0347335374e363432711ad9f0ba02badefb300b /test/functional/ex_cmds/trust_spec.lua
parentbb369a14f3e948c8efa3709d95e4dc2098b2de6a (diff)
downloadrneovim-9b9f8dfcc41ceb80d3970eb58af8ee350b57dc7f.tar.gz
rneovim-9b9f8dfcc41ceb80d3970eb58af8ee350b57dc7f.tar.bz2
rneovim-9b9f8dfcc41ceb80d3970eb58af8ee350b57dc7f.zip
test: make {MATCH:} behave less unexpectedly in screen:expect()
Include the rest of the line and allow multiple {MATCH:} patterns.
Diffstat (limited to 'test/functional/ex_cmds/trust_spec.lua')
-rw-r--r--test/functional/ex_cmds/trust_spec.lua117
1 files changed, 10 insertions, 107 deletions
diff --git a/test/functional/ex_cmds/trust_spec.lua b/test/functional/ex_cmds/trust_spec.lua
index 10ee02a790..fe13bd7cd2 100644
--- a/test/functional/ex_cmds/trust_spec.lua
+++ b/test/functional/ex_cmds/trust_spec.lua
@@ -1,9 +1,10 @@
local helpers = require('test.functional.helpers')(after_each)
-local Screen = require('test.functional.ui.screen')
local eq = helpers.eq
local clear = helpers.clear
local command = helpers.command
+local exec_capture = helpers.exec_capture
+local matches = helpers.matches
local pathsep = helpers.get_pathsep()
local is_os = helpers.is_os
local funcs = helpers.funcs
@@ -29,147 +30,49 @@ describe(':trust', function()
end)
it('trust then deny then remove a file using current buffer', function()
- local screen = Screen.new(80, 8)
- screen:attach()
- screen:set_default_attr_ids({
- [1] = {bold = true, foreground = Screen.colors.Blue1},
- })
-
local cwd = funcs.getcwd()
local hash = funcs.sha256(helpers.read_file('test_file'))
command('edit test_file')
- command('trust')
- screen:expect([[
- ^test |
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- "]] .. cwd .. pathsep .. [[test_file" trusted.{MATCH:%s+}|
- ]])
+ matches('^Allowed ".*test_file" in trust database%.$', exec_capture('trust'))
local trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
eq(string.format('%s %s', hash, cwd .. pathsep .. 'test_file'), vim.trim(trust))
- command('trust ++deny')
- screen:expect([[
- ^test |
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- "]] .. cwd .. pathsep .. [[test_file" denied.{MATCH:%s+}|
- ]])
+ matches('^Denied ".*test_file" in trust database%.$', exec_capture('trust ++deny'))
trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
eq(string.format('! %s', cwd .. pathsep .. 'test_file'), vim.trim(trust))
- command('trust ++remove')
- screen:expect([[
- ^test |
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- "]] .. cwd .. pathsep .. [[test_file" removed.{MATCH:%s+}|
- ]])
+ matches('^Removed ".*test_file" from trust database%.$', exec_capture('trust ++remove'))
trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
eq(string.format(''), vim.trim(trust))
end)
it('deny then trust then remove a file using current buffer', function()
- local screen = Screen.new(80, 8)
- screen:attach()
- screen:set_default_attr_ids({
- [1] = {bold = true, foreground = Screen.colors.Blue1},
- })
-
local cwd = funcs.getcwd()
local hash = funcs.sha256(helpers.read_file('test_file'))
command('edit test_file')
- command('trust ++deny')
- screen:expect([[
- ^test |
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- "]] .. cwd .. pathsep .. [[test_file" denied.{MATCH:%s+}|
- ]])
+ matches('^Denied ".*test_file" in trust database%.$', exec_capture('trust ++deny'))
local trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
eq(string.format('! %s', cwd .. pathsep .. 'test_file'), vim.trim(trust))
- command('trust')
- screen:expect([[
- ^test |
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- "]] .. cwd .. pathsep .. [[test_file" trusted.{MATCH:%s+}|
- ]])
+ matches('^Allowed ".*test_file" in trust database%.$', exec_capture('trust'))
trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
eq(string.format('%s %s', hash, cwd .. pathsep .. 'test_file'), vim.trim(trust))
- command('trust ++remove')
- screen:expect([[
- ^test |
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- "]] .. cwd .. pathsep .. [[test_file" removed.{MATCH:%s+}|
- ]])
+ matches('^Removed ".*test_file" from trust database%.$', exec_capture('trust ++remove'))
trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
eq(string.format(''), vim.trim(trust))
end)
it('deny then remove a file using file path', function()
- local screen = Screen.new(80, 8)
- screen:attach()
- screen:set_default_attr_ids({
- [1] = {bold = true, foreground = Screen.colors.Blue1},
- })
-
local cwd = funcs.getcwd()
- command('trust ++deny test_file')
- screen:expect([[
- ^ |
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- "]] .. cwd .. pathsep .. [[test_file" denied.{MATCH:%s+}|
- ]])
+ matches('^Denied ".*test_file" in trust database%.$', exec_capture('trust ++deny test_file'))
local trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
eq(string.format('! %s', cwd .. pathsep .. 'test_file'), vim.trim(trust))
- command('trust ++remove test_file')
- screen:expect([[
- ^ |
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- "]] .. cwd .. pathsep .. [[test_file" removed.{MATCH:%s+}|
- ]])
+ matches('^Removed ".*test_file" from trust database%.$', exec_capture('trust ++remove test_file'))
trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
eq(string.format(''), vim.trim(trust))
end)