sequences

pull/28/head
ray-x 3 years ago
parent af25e1e2e7
commit bdce678adf

@ -92,6 +92,31 @@ describe("should run gofmt", function()
cmd = "bd! " .. name
vim.cmd(cmd)
end)
it("should run import from file buffer with goimport", function()
_GO_NVIM_CFG.goimport = 'goimport'
local path = cur_dir .. "/lua/tests/fixtures/fmt/goimports.go" -- %:p:h ? %:p
local expected = vim.fn.join(vim.fn.readfile(cur_dir
.. "/lua/tests/fixtures/fmt/goimports_golden.go"),
"\n")
local name = vim.fn.tempname() .. ".go"
print(name)
local lines = vim.fn.readfile(path)
local cmd = " silent exe 'e " .. name .. "'"
vim.fn.writefile(lines, name)
vim.cmd(cmd)
vim.cmd([[cd %:p:h]])
print("code write to " .. name)
local gofmt = require("go.format")
gofmt.goimport(true)
vim.wait(100, function()
end)
local fmt = vim.fn.join(vim.fn.readfile(name), "\n")
print(fmt)
eq(expected, fmt)
end)
it("should run import from file with gopls", function()
local path = cur_dir .. "/lua/tests/fixtures/fmt/goimports2.go" -- %:p:h ? %:p
local expected = vim.fn.join(vim.fn.readfile(cur_dir
@ -100,7 +125,6 @@ describe("should run gofmt", function()
_GO_NVIM_CFG.goimport = 'gopls'
local lines = vim.fn.readfile(path)
local cmd = " silent exe 'e " .. path .. "'"
vim.cmd(cmd)
@ -123,28 +147,4 @@ describe("should run gofmt", function()
cmd = "bd! " .. path
vim.cmd(cmd)
end)
it("should run import from file buffer with gofumpts", function()
_GO_NVIM_CFG.goimport = 'gofumports'
local path = cur_dir .. "/lua/tests/fixtures/fmt/goimports.go" -- %:p:h ? %:p
local expected = vim.fn.join(vim.fn.readfile(cur_dir
.. "/lua/tests/fixtures/fmt/goimports_golden.go"),
"\n")
local name = vim.fn.tempname() .. ".go"
print(name)
local lines = vim.fn.readfile(path)
local cmd = " silent exe 'e " .. name .. "'"
vim.fn.writefile(lines, name)
vim.cmd(cmd)
vim.cmd([[cd %:p:h]])
print("code write to " .. name)
local gofmt = require("go.format")
gofmt.goimport(true)
vim.wait(100, function()
end)
local fmt = vim.fn.join(vim.fn.readfile(name), "\n")
print(fmt)
eq(expected, fmt)
end)
end)

Loading…
Cancel
Save