chore: improve test coverage
parent
23151e4db6
commit
f886f9a2ec
|
|
@ -1,4 +1,3 @@
|
|||
plenary.nvim/
|
||||
tests/default_data/
|
||||
tests/custom_data/
|
||||
!tests/**/*
|
||||
.luarc.json
|
||||
|
|
|
|||
3
Makefile
3
Makefile
|
|
@ -1,7 +1,10 @@
|
|||
all: test
|
||||
|
||||
test:
|
||||
nvim --headless --noplugin -u tests/minimal.vim +Setup
|
||||
nvim --headless --noplugin -u tests/minimal.vim +TestAutoloading
|
||||
nvim --headless --noplugin -u tests/minimal.vim +Test
|
||||
nvim --headless --noplugin -u tests/minimal.vim +TearDown
|
||||
|
||||
check:
|
||||
stylua --color always --check .
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
local e = vim.fn.fnameescape
|
||||
local session_dir = vim.fn.getcwd() .. "/tests/dummy_data/"
|
||||
require("persisted").setup({
|
||||
dir = session_dir,
|
||||
autoload = true,
|
||||
autosave = true,
|
||||
allowed_dirs = { vim.fn.getcwd() },
|
||||
})
|
||||
|
||||
describe("With custom settings:", function()
|
||||
|
||||
-- after_each(function()
|
||||
-- vim.fn.system("rm -rf " .. e(session_dir))
|
||||
-- end)
|
||||
|
||||
it("autoloads a file with allowed_dirs", function()
|
||||
local content = vim.fn.getline(1, '$')
|
||||
assert.equals(content[1], "If you're reading this, I guess auto-loading works")
|
||||
end)
|
||||
|
||||
end)
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
local e = vim.fn.fnameescape
|
||||
local session_dir = vim.fn.getcwd() .. "/tests/dummy_data/"
|
||||
require("persisted").setup({
|
||||
dir = session_dir,
|
||||
autoload = true,
|
||||
autosave = true,
|
||||
})
|
||||
|
||||
describe("With custom settings:", function()
|
||||
|
||||
it("autoloads a file", function()
|
||||
local content = vim.fn.getline(1, '$')
|
||||
assert.equals(content[1], "If you're reading this, I guess auto-loading works")
|
||||
end)
|
||||
|
||||
end)
|
||||
|
|
@ -8,4 +8,7 @@ set noswapfile
|
|||
set noundofile
|
||||
|
||||
runtime plugin/plenary.vim
|
||||
command Setup PlenaryBustedFile tests/setup/create_sessions_spec.lua
|
||||
command TestAutoloading PlenaryBustedDirectory tests/autoload {minimal_init = 'tests/minimal.vim'}
|
||||
command Test PlenaryBustedDirectory tests/ {minimal_init = 'tests/minimal.vim'}
|
||||
command TearDown PlenaryBustedFile tests/teardown/clean_up_dirs.lua
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
pcall(vim.fn.system, "rm -rf tests/dummy_data")
|
||||
|
||||
local session_dir = vim.fn.getcwd() .. "/tests/dummy_data/"
|
||||
require("persisted").setup({
|
||||
dir = session_dir,
|
||||
autoload = true,
|
||||
autosave = true,
|
||||
})
|
||||
|
||||
describe("As part of the setup", function()
|
||||
it("a session is created to autoload from", function()
|
||||
|
||||
vim.cmd(":e tests/stubs/test_autoload.txt")
|
||||
vim.cmd(":w")
|
||||
|
||||
require("persisted").save()
|
||||
end)
|
||||
-- it("autoloads a file", function()
|
||||
-- local content = vim.fn.getline(1, '$')
|
||||
-- assert.equals(content[1], "This is a test file for custom config")
|
||||
-- end)
|
||||
end)
|
||||
|
|
@ -0,0 +1 @@
|
|||
If you're reading this, I guess auto-loading works
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
describe("As part of the teardown", function()
|
||||
it("dummy data is deleted", function()
|
||||
pcall(vim.fn.system, "rm -rf tests/dummy_data")
|
||||
pcall(vim.fn.system, "rm -rf tests/default_data")
|
||||
end)
|
||||
end)
|
||||
Loading…
Reference in New Issue