go mod setup for fixtures

pull/392/head
ray-x 8 months ago
parent c4819d1625
commit 561e9f74d9

@ -1,4 +1,4 @@
package main
package coverage
// import "fmt"

@ -1,4 +1,4 @@
package main
package coverage
import "testing"

@ -1,3 +0,0 @@
module github.com/ray-x/go.nvim/lua/tests/fixtures/coverage
go 1.21.1

@ -1,6 +1,6 @@
//+build integration,unit
package main
package coverage
func TestTag(t *testing.T) {
t.Log("TestTag")

@ -1,3 +0,0 @@
module github.com/ray-x/go.nvim/lua/tests/fixtures/fill
go 1.21.1

@ -1,3 +0,0 @@
module github.com/ray-x/go.nvim/lua/tests/fixtures/fixplurals
go 1.21.1

@ -1,3 +0,0 @@
module github.com/ray-x/go.nvim/lua/tests/fixtures/fmt
go 1.21.1

@ -0,0 +1,3 @@
module fixtures
go 1.21.1

@ -1,3 +0,0 @@
module github.com/ray-x/go.nvim/lua/tests/fixtures/ts
go 1.21.1

@ -1,44 +1,49 @@
local eq = assert.are.same
local cur_dir = vim.fn.expand("%:p:h")
local busted = require("plenary/busted")
local cur_dir = vim.fn.expand('%:p:h')
local busted = require('plenary/busted')
describe("should run func make", function()
describe('should run func make', function()
-- vim.fn.readfile('minimal.vim')
-- vim.fn.writefile(vim.fn.readfile('fixtures/fmt/hello.go'), name)
require("plenary.reload").reload_module("go.nvim")
it("should make function", function()
require('plenary.reload').reload_module('go.nvim')
it('should make function', function()
--
-- go.nvim may not auto loaded
vim.cmd([[packadd go.nvim]])
local path = cur_dir .. "/lua/tests/fixtures/coverage/branch_test.go" -- %:p:h ? %:p
require("go").setup({
local path = cur_dir .. '/lua/tests/fixtures/'
local fname = 'coverage/branch_test.go' -- %:p:h ? %:p
require('go').setup({
trace = true,
lsp_cfg = true,
log_path = vim.fn.expand("$HOME") .. "/tmp/gonvim.log",
log_path = vim.fn.expand('$HOME') .. '/tmp/gonvim.log',
})
vim.cmd("silent exe 'e " .. path .. "'")
vim.fn.setpos(".", { 0, 5, 11, 0 })
local cmd = require("go.asyncmake").make('go', 'vet', '.')
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')
print(vim.inspect(cmd))
eq({ "go", "vet", "."}, cmd)
eq({ 'go', 'vet', '.' }, cmd)
end)
it("should make function inside a source code", function()
it('should make function inside a source code', function()
--
-- go.nvim may not auto loaded
vim.cmd([[packadd go.nvim]])
local path = cur_dir .. "/lua/tests/fixtures/coverage/branch.go" -- %:p:h ? %:p
require("go").setup({
local path = cur_dir .. '/lua/tests/fixtures/'
local fname = './coverage/branch.go' -- %:p:h ? %:p
require('go').setup({
trace = true,
lsp_cfg = true,
log_path = vim.fn.expand("$HOME") .. "/tmp/gonvim.log",
log_path = vim.fn.expand('$HOME') .. '/tmp/gonvim.log',
})
vim.cmd("silent exe 'e " .. path .. "'")
vim.fn.setpos(".", { 0, 6, 11, 0 })
local cmd = require("go.asyncmake").make('go', 'test', './...')
eq({ "go", "test", "./..."}, cmd)
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')
eq({ 'go', 'test', 'coverage' }, cmd)
end)
end)

@ -1,7 +1,7 @@
local eq = assert.are.same
local cur_dir = vim.fn.expand('%:p:h')
local busted = require('plenary/busted')
local godir = cur_dir .. ''
describe('should run func test', function()
-- vim.fn.readfile('minimal.vim')
-- vim.fn.writefile(vim.fn.readfile('fixtures/fmt/hello.go'), name)
@ -11,49 +11,53 @@ describe('should run func test', function()
-- go.nvim may not auto loaded
vim.cmd([[packadd go.nvim]])
local path = cur_dir .. '/lua/tests/fixtures/coverage/branch_test.go' -- %:p:h ? %:p
local path = './coverage/branch_test.go' -- %:p:h ? %:p
require('go').setup({
trace = true,
lsp_cfg = true,
log_path = vim.fn.expand('$HOME') .. '/tmp/gonvim.log',
test_runner = 'go',
})
vim.cmd('cd ' .. godir)
vim.cmd("silent exe 'e " .. path .. "'")
vim.fn.setpos('.', { 0, 5, 11, 0 })
local cmd = require('go.gotest').test_func()
eq({ 'go', 'test', './lua/tests/fixtures/coverage', '-run', [['^Test_branch$']] }, cmd)
eq({ 'go', 'test', './coverage', '-run', [['^Test_branch$']] }, cmd)
end)
it('should test function inside a source code', function()
--
-- go.nvim may not auto loaded
vim.cmd([[packadd go.nvim]])
local path = cur_dir .. '/lua/tests/fixtures/coverage/branch.go' -- %:p:h ? %:p
local path = './coverage/branch.go' -- %:p:h ? %:p
require('go').setup({
trace = true,
lsp_cfg = true,
log_path = vim.fn.expand('$HOME') .. '/tmp/gonvim.log',
test_runner = 'go',
})
vim.cmd('cd ' .. godir)
vim.cmd("silent exe 'e " .. path .. "'")
vim.fn.setpos('.', { 0, 6, 11, 0 })
local cmd = require('go.gotest').test_func()
eq({ 'go', 'test', './lua/tests/fixtures/coverage', '-run', [['^Test_branch$']] }, cmd)
eq({ 'go', 'test', './coverage', '-run', [['^Test_branch$']] }, cmd)
end)
it('should test function with additional args to test binary', function()
--
-- go.nvim may not auto loaded
vim.cmd([[packadd go.nvim]])
local path = cur_dir .. '/lua/tests/fixtures/coverage/branch_test.go' -- %:p:h ? %:p
local path = 'coverage/branch_test.go' -- %:p:h ? %:p
require('go').setup({
trace = true,
lsp_cfg = true,
log_path = vim.fn.expand('$HOME') .. '/tmp/gonvim.log',
test_runner = 'go',
})
vim.cmd('cd ' .. godir)
vim.cmd("silent exe 'e " .. path .. "'")
vim.fn.setpos('.', { 0, 5, 11, 0 })
local cmd = require('go.gotest').test_func('-a', 'mock=true')
@ -61,7 +65,7 @@ describe('should run func test', function()
eq({
'go',
'test',
'./lua/tests/fixtures/coverage',
'./coverage',
'-args',
'mock=true',
'-run',
@ -79,13 +83,14 @@ describe('should run test file', function()
-- go.nvim may not auto loaded
vim.cmd([[packadd go.nvim]])
local path = cur_dir .. '/lua/tests/fixtures/coverage/branch_test.go' -- %:p:h ? %:p
local path = 'coverage/branch_test.go' -- %:p:h ? %:p
require('go').setup({
trace = true,
lsp_cfg = true,
log_path = vim.fn.expand('$HOME') .. '/tmp/gonvim.log',
test_runner = 'go',
})
vim.cmd('cd ' .. godir)
vim.cmd("silent exe 'e " .. path .. "'")
vim.fn.setpos('.', { 0, 5, 11, 0 })
local cmd = require('go.gotest').test_file()
@ -109,12 +114,13 @@ describe('should run test file with flags', function()
-- go.nvim may not auto loaded
vim.cmd([[packadd go.nvim]])
local path = cur_dir .. '/lua/tests/fixtures/coverage/branch_test.go' -- %:p:h ? %:p
local path = 'coverage/branch_test.go' -- %:p:h ? %:p
require('go').setup({
trace = true,
lsp_cfg = true,
log_path = vim.fn.expand('$HOME') .. '/tmp/gonvim.log',
})
vim.cmd('cd ' .. godir)
vim.cmd("silent exe 'e " .. path .. "'")
vim.fn.setpos('.', { 0, 5, 11, 0 })
local cmd = require('go.gotest').test_file('-t', 'tag1')
@ -139,7 +145,7 @@ describe('should run test package', function()
-- go.nvim may not auto loaded
vim.cmd([[packadd go.nvim]])
local path = cur_dir .. '/lua/tests/fixtures/coverage/branch_test.go' -- %:p:h ? %:p
local path = 'coverage/branch_test.go' -- %:p:h ? %:p
require('go').setup({
trace = true,
lsp_cfg = true,
@ -149,7 +155,7 @@ describe('should run test package', function()
vim.fn.setpos('.', { 0, 1, 1, 0 })
local cmd = require('go.gotest').test_package()
eq({ 'go', 'test', './lua/tests/fixtures/coverage/...' }, cmd)
eq({ 'go', 'test', './coverage/...' }, cmd)
end)
end)
@ -162,19 +168,17 @@ describe('should run test ', function()
-- go.nvim may not auto loaded
vim.cmd([[packadd go.nvim]])
local path = cur_dir .. '/lua/tests/fixtures/coverage/branch_test.go' -- %:p:h ? %:p
local path = 'coverage/branch_test.go' -- %:p:h ? %:p
require('go').setup({
trace = true,
lsp_cfg = true,
})
vim.cmd('cd ' .. godir)
vim.cmd("silent exe 'e " .. path .. "'")
vim.fn.setpos('.', { 0, 6, 1, 0 })
local cmd = require('go.gotest').test('-n', '-t', 'tags1')
eq(
{ 'go', 'test', '-tags=tags1', './lua/tests/fixtures/coverage', '-run', [['^Test_branch$']] },
cmd
)
eq({ 'go', 'test', '-tags=tags1', './coverage', '-run', [['^Test_branch$']] }, cmd)
end)
end)
@ -188,7 +192,7 @@ describe('should allow select test func', function()
-- go.nvim may not auto loaded
vim.cmd([[packadd go.nvim]])
local path = cur_dir .. '/lua/tests/fixtures/coverage/branch_test.go' -- %:p:h ? %:p
local path = 'coverage/branch_test.go' -- %:p:h ? %:p
require('go').setup({
trace = true,
lsp_cfg = true,
@ -211,12 +215,13 @@ describe('should run test file with flags inside file', function()
-- go.nvim may not auto loaded
vim.cmd([[packadd go.nvim]])
local path = cur_dir .. '/lua/tests/fixtures/coverage/tag_test.go' -- %:p:h ? %:p
local path = 'coverage/tag_test.go' -- %:p:h ? %:p
require('go').setup({
trace = true,
lsp_cfg = true,
log_path = vim.fn.expand('$HOME') .. '/tmp/gonvim.log',
})
vim.cmd('cd ' .. godir)
vim.cmd("silent exe 'e " .. path .. "'")
vim.fn.setpos('.', { 1, 1, 1, 0 })
local cmd = require('go.gotest').test_file('-t', 'tag1')
@ -239,69 +244,67 @@ describe('should run subcase test', function()
-- go.nvim may not auto loaded
vim.cmd([[packadd go.nvim]])
local path = cur_dir .. '/lua/tests/fixtures/coverage/branch_test.go'
local path = 'coverage/branch_test.go'
require('go').setup({
trace = true,
lsp_cfg = true,
log_path = vim.fn.expand('$HOME') .. '/tmp/gonvim.log',
})
vim.cmd('cd ' .. godir)
vim.cmd("silent exe 'e " .. path .. "'")
vim.fn.setpos('.', { 1, 18, 11, 0 })
local cmd = require('go.gotest').test_tblcase()
eq({ 'go', 'test', './lua/tests/fixtures/coverage', '-run', [['^Test_branch$'/"a10"]] }, cmd)
eq({ 'go', 'test', './coverage', '-run', [['^Test_branch$'/"a10"]] }, cmd)
end)
it('should test subcase in table test style when cursor inside test block', function()
-- go.nvim may not auto loaded
vim.cmd([[packadd go.nvim]])
local path = cur_dir .. '/lua/tests/fixtures/coverage/branch_test.go'
local path = 'coverage/branch_test.go'
require('go').setup({
trace = true,
lsp_cfg = true,
log_path = vim.fn.expand('$HOME') .. '/tmp/gonvim.log',
})
vim.cmd('cd ' .. godir)
vim.cmd("silent exe 'e " .. path .. "'")
vim.fn.setpos('.', { 1, 29, 12, 0 })
local cmd = require('go.gotest').test_tblcase()
eq({ 'go', 'test', './lua/tests/fixtures/coverage', '-run', [['^Test_branch$'/"b10"]] }, cmd)
eq({ 'go', 'test', './coverage', '-run', [['^Test_branch$'/"b10"]] }, cmd)
end)
it('should test subcase in subtest style', function()
-- go.nvim may not auto loaded
vim.cmd([[packadd go.nvim]])
local path = cur_dir .. '/lua/tests/fixtures/coverage/branch_test.go'
local path = 'coverage/branch_test.go'
require('go').setup({
trace = true,
lsp_cfg = true,
log_path = vim.fn.expand('$HOME') .. '/tmp/gonvim.log',
})
vim.cmd('cd ' .. godir)
vim.cmd("silent exe 'e " .. path .. "'")
vim.fn.setpos('.', { 1, 75, 11, 0 })
local cmd = require('go.gotest').test_tblcase()
eq(
{ 'go', 'test', './lua/tests/fixtures/coverage', '-run', [['^TestBranchSubTest$'/"a11"]] },
cmd
)
eq({ 'go', 'test', './coverage', '-run', [['^TestBranchSubTest$'/"a11"]] }, cmd)
end)
it('should test subcase in subtest style when cursor insde test block', function()
-- go.nvim may not auto loaded
vim.cmd([[packadd go.nvim]])
local path = cur_dir .. '/lua/tests/fixtures/coverage/branch_test.go'
local path = 'coverage/branch_test.go'
require('go').setup({
trace = true,
lsp_cfg = true,
log_path = vim.fn.expand('$HOME') .. '/tmp/gonvim.log',
})
vim.cmd('cd ' .. godir)
vim.cmd("silent exe 'e " .. path .. "'")
vim.fn.setpos('.', { 1, 82, 7, 0 })
local cmd = require('go.gotest').test_tblcase()
eq(
{ 'go', 'test', './lua/tests/fixtures/coverage', '-run', [['^TestBranchSubTest$'/"b11"]] },
cmd
)
eq({ 'go', 'test', './coverage', '-run', [['^TestBranchSubTest$'/"b11"]] }, cmd)
end)
end)

Loading…
Cancel
Save