2022-07-07 22:30:46 +00:00
|
|
|
local eq = assert.are.same
|
2023-10-31 12:24:08 +00:00
|
|
|
local cur_dir = vim.fn.expand('%:p:h')
|
|
|
|
local busted = require('plenary/busted')
|
2022-07-07 22:30:46 +00:00
|
|
|
|
2023-10-31 12:24:08 +00:00
|
|
|
describe('should run func make', function()
|
2022-07-07 22:30:46 +00:00
|
|
|
-- vim.fn.readfile('minimal.vim')
|
|
|
|
-- vim.fn.writefile(vim.fn.readfile('fixtures/fmt/hello.go'), name)
|
2023-10-31 12:24:08 +00:00
|
|
|
require('plenary.reload').reload_module('go.nvim')
|
|
|
|
it('should make function', function()
|
2022-07-07 22:30:46 +00:00
|
|
|
--
|
|
|
|
-- go.nvim may not auto loaded
|
|
|
|
vim.cmd([[packadd go.nvim]])
|
|
|
|
|
2023-10-31 12:24:08 +00:00
|
|
|
local path = cur_dir .. '/lua/tests/fixtures/'
|
|
|
|
local fname = 'coverage/branch_test.go' -- %:p:h ? %:p
|
|
|
|
require('go').setup({
|
2022-07-07 22:30:46 +00:00
|
|
|
trace = true,
|
|
|
|
lsp_cfg = true,
|
2023-10-31 12:24:08 +00:00
|
|
|
log_path = vim.fn.expand('$HOME') .. '/tmp/gonvim.log',
|
2022-07-07 22:30:46 +00:00
|
|
|
})
|
2023-10-31 12:24:08 +00:00
|
|
|
vim.cmd("silent cd " .. path)
|
|
|
|
vim.cmd("silent exe 'e " .. fname .. "'")
|
|
|
|
vim.fn.setpos('.', { 0, 5, 11, 0 })
|
|
|
|
local cmd = require('go.asyncmake').make('go', 'vet', './coverage')
|
2022-07-07 22:30:46 +00:00
|
|
|
print(vim.inspect(cmd))
|
|
|
|
|
2023-10-31 12:43:46 +00:00
|
|
|
eq({ 'go', 'vet', './coverage' }, cmd)
|
2022-07-07 22:30:46 +00:00
|
|
|
end)
|
2023-10-31 12:24:08 +00:00
|
|
|
it('should make function inside a source code', function()
|
2022-07-07 22:30:46 +00:00
|
|
|
--
|
|
|
|
-- go.nvim may not auto loaded
|
|
|
|
vim.cmd([[packadd go.nvim]])
|
|
|
|
|
2023-10-31 12:24:08 +00:00
|
|
|
local path = cur_dir .. '/lua/tests/fixtures/'
|
|
|
|
local fname = './coverage/branch.go' -- %:p:h ? %:p
|
|
|
|
require('go').setup({
|
2022-07-07 22:30:46 +00:00
|
|
|
trace = true,
|
|
|
|
lsp_cfg = true,
|
2023-10-31 12:24:08 +00:00
|
|
|
log_path = vim.fn.expand('$HOME') .. '/tmp/gonvim.log',
|
2022-07-07 22:30:46 +00:00
|
|
|
})
|
|
|
|
|
2023-10-31 12:24:08 +00:00
|
|
|
vim.cmd("silent cd " .. path)
|
|
|
|
vim.cmd("silent exe 'e " .. fname .. "'")
|
|
|
|
vim.fn.setpos('.', { 0, 6, 11, 0 })
|
|
|
|
local cmd = require('go.asyncmake').make('go', 'test', './coverage')
|
|
|
|
|
2023-10-31 12:43:46 +00:00
|
|
|
eq({ 'go', 'test', './coverage' }, cmd)
|
2022-07-07 22:30:46 +00:00
|
|
|
end)
|
|
|
|
end)
|