test: fix test for command line output

main
olimorris 2022-10-07 12:46:25 +01:00
parent a449cd5a73
commit 3bf38d98b7
2 changed files with 6 additions and 5 deletions

View File

@ -10,7 +10,7 @@ describe("With default settings:", function()
it("saves a session", function() it("saves a session", function()
-- Check no file exists -- Check no file exists
assert.equals(vim.fn.system("ls tests/default_data | wc -l"), "0\n") assert.equals(vim.fn.system("ls tests/default_data | wc -l"):gsub("%s+", ""), "0")
-- Edit a buffer -- Edit a buffer
vim.cmd(":e tests/stubs/test.txt") vim.cmd(":e tests/stubs/test.txt")
@ -21,7 +21,7 @@ describe("With default settings:", function()
-- Check that the session is written to disk -- Check that the session is written to disk
assert.equals(vim.g.persisting, true) assert.equals(vim.g.persisting, true)
assert.equals(vim.fn.system("ls tests/default_data | wc -l"), "1\n") assert.equals(vim.fn.system("ls tests/default_data | wc -l"):gsub("%s+", ""), "1")
end) end)
it("loads a session", function() it("loads a session", function()
@ -57,7 +57,7 @@ describe("With default settings:", function()
it("deletes a session", function() it("deletes a session", function()
require("persisted").delete() require("persisted").delete()
assert.equals(vim.fn.system("ls tests/default_data | wc -l"), "0\n") assert.equals(vim.fn.system("ls tests/default_data | wc -l"):gsub("%s+", ""), "0")
end) end)
end) end)

View File

@ -11,13 +11,14 @@ describe("Git Branching", function()
vim.fn.system("mkdir tests/git_branch_data") vim.fn.system("mkdir tests/git_branch_data")
vim.fn.system("cd tests/git_branch_data && git init") vim.fn.system("cd tests/git_branch_data && git init")
assert.equals(vim.fn.system("ls tests/git_branch_data | wc -l"), "0\n") assert.equals(vim.fn.system("ls tests/git_branch_data | wc -l"):gsub("%s+", ""), "0")
vim.cmd(":e tests/stubs/test_git_branching.txt") vim.cmd(":e tests/stubs/test_git_branching.txt")
vim.cmd(":w tests/git_branch_data/test_git_branching.txt") vim.cmd(":w tests/git_branch_data/test_git_branching.txt")
require("persisted").save() require("persisted").save()
assert.equals(vim.fn.system("ls tests/git_branch_data | wc -l"), "2\n") assert.equals(vim.fn.system("ls tests/git_branch_data | wc -l"):gsub("%s+", ""), "2")
end) end)
it("ensures the session has the branch name in", function() it("ensures the session has the branch name in", function()