fix TSamFailedOnly and the output formatting for the go-runner
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
local go_runner = require("test-samurai.runners.go")
|
||||
local util = require("test-samurai.util")
|
||||
|
||||
describe("test-samurai go runner", function()
|
||||
it("detects Go test files by suffix", function()
|
||||
@@ -112,4 +113,35 @@ describe("test-samurai go runner", function()
|
||||
cmd_spec_func.cmd
|
||||
)
|
||||
end)
|
||||
|
||||
it("build_file_command uses exact test names from current file", function()
|
||||
local bufnr = vim.api.nvim_create_buf(false, true)
|
||||
vim.api.nvim_buf_set_name(bufnr, "/tmp/project/get_test.go")
|
||||
local lines = {
|
||||
"package main",
|
||||
"import \"testing\"",
|
||||
"",
|
||||
"func TestHandleGet(t *testing.T) {",
|
||||
" t.Run(\"returns_200\", func(t *testing.T) {",
|
||||
" -- inside test",
|
||||
" })",
|
||||
"}",
|
||||
}
|
||||
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, lines)
|
||||
|
||||
local orig_find_root = util.find_root
|
||||
util.find_root = function(path, markers)
|
||||
return "/tmp/project"
|
||||
end
|
||||
|
||||
local cmd_spec = go_runner.build_file_command(bufnr)
|
||||
|
||||
util.find_root = orig_find_root
|
||||
|
||||
assert.are.same(
|
||||
{ "go", "test", "-json", "./", "-run", "^(TestHandleGet)$" },
|
||||
cmd_spec.cmd
|
||||
)
|
||||
assert.equals("/tmp/project", cmd_spec.cwd)
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user