chore: add git branch tests
parent
7f88f8a64c
commit
f2478ae42d
1
Makefile
1
Makefile
|
|
@ -3,6 +3,7 @@ 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 +TestGitBranching
|
||||
nvim --headless --noplugin -u tests/minimal.vim +Test
|
||||
nvim --headless --noplugin -u tests/minimal.vim +TearDown
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
pcall(vim.fn.system, "rm -rf tests/git_branch_data")
|
||||
|
||||
local session_dir = vim.fn.getcwd() .. "/tests/git_branch_data/"
|
||||
require("persisted").setup({
|
||||
dir = session_dir,
|
||||
use_git_branch = true,
|
||||
})
|
||||
|
||||
describe("Git Branching", function()
|
||||
it("creates a session", function()
|
||||
vim.fn.system("mkdir tests/git_branch_data")
|
||||
vim.fn.system("cd tests/git_branch_data && git init")
|
||||
|
||||
assert.equals(vim.fn.system("ls tests/git_branch_data | wc -l"), "0\n")
|
||||
|
||||
vim.cmd(":e tests/stubs/test_git_branching.txt")
|
||||
vim.cmd(":w tests/git_branch_data/test_git_branching.txt")
|
||||
|
||||
require("persisted").save()
|
||||
assert.equals(vim.fn.system("ls tests/git_branch_data | wc -l"), "2\n")
|
||||
end)
|
||||
|
||||
it("ensures the session has the branch name in", function()
|
||||
-- Workout what the name should be
|
||||
local pattern = "/"
|
||||
local name = vim.fn.getcwd():gsub(pattern, "%%") .. "_main.vim"
|
||||
local session = vim.fn.glob(session_dir .. "*.vim", true, true)[1]
|
||||
|
||||
session:gsub(session_dir .. "/", "")
|
||||
assert.equals(session, vim.fn.getcwd() .. "/tests/git_branch_data/" .. name)
|
||||
-- assert.equals(sessions[1]:gsub(pattern, "%%"), name)
|
||||
end)
|
||||
end)
|
||||
|
|
@ -8,7 +8,8 @@ set noswapfile
|
|||
set noundofile
|
||||
|
||||
runtime plugin/plenary.vim
|
||||
command Setup PlenaryBustedFile tests/setup/create_sessions_spec.lua
|
||||
command Setup PlenaryBustedDirectory tests/setup {minimal_init = 'tests/minimal.vim'}
|
||||
command TestAutoloading PlenaryBustedDirectory tests/autoload {minimal_init = 'tests/minimal.vim'}
|
||||
command TestGitBranching PlenaryBustedDirectory tests/git_branching {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 @@
|
|||
Git branching is awesome
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
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/git_branch_data")
|
||||
pcall(vim.fn.system, "rm -rf tests/default_data")
|
||||
end)
|
||||
end)
|
||||
|
|
|
|||
Loading…
Reference in New Issue