fix TSamFailedOnly and the output formatting for the go-runner
This commit is contained in:
@@ -54,6 +54,57 @@ describe("TSamLast", function()
|
||||
assert.equals(calls[1].opts.cwd, calls[2].opts.cwd)
|
||||
end)
|
||||
|
||||
it("uses go parser for TSamLast output (no raw JSON)", function()
|
||||
local json_line = vim.json.encode({
|
||||
Action = "fail",
|
||||
Test = "TestHandleGet/returns_200",
|
||||
})
|
||||
|
||||
local calls = {}
|
||||
local orig_jobstart = vim.fn.jobstart
|
||||
vim.fn.jobstart = function(cmd, opts)
|
||||
table.insert(calls, { cmd = cmd, opts = opts })
|
||||
if opts and opts.on_stdout then
|
||||
opts.on_stdout(1, { json_line }, nil)
|
||||
end
|
||||
if opts and opts.on_exit then
|
||||
opts.on_exit(1, 1, nil)
|
||||
end
|
||||
return 1
|
||||
end
|
||||
|
||||
local bufnr = mkbuf("/tmp/project/foo_last_output_test.go", "go", {
|
||||
"package main",
|
||||
"import \"testing\"",
|
||||
"",
|
||||
"func TestHandleGet(t *testing.T) {",
|
||||
" t.Run(\"returns_200\", func(t *testing.T) {",
|
||||
" -- inside test",
|
||||
" })",
|
||||
"}",
|
||||
})
|
||||
|
||||
vim.api.nvim_set_current_buf(bufnr)
|
||||
|
||||
core.run_all()
|
||||
core.run_last()
|
||||
|
||||
local out_buf = vim.api.nvim_get_current_buf()
|
||||
local lines = vim.api.nvim_buf_get_lines(out_buf, 0, -1, false)
|
||||
|
||||
vim.fn.jobstart = orig_jobstart
|
||||
|
||||
assert.equals(2, #calls)
|
||||
local has_raw = false
|
||||
for _, line in ipairs(lines) do
|
||||
if line == json_line then
|
||||
has_raw = true
|
||||
break
|
||||
end
|
||||
end
|
||||
assert.is_false(has_raw)
|
||||
end)
|
||||
|
||||
it("reruns last JS command", function()
|
||||
local calls, orig_jobstart = capture_jobstart()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user