test(iferr): add test

chore(ci): install go, and go bins for tests
This commit is contained in:
Oleksandr Smirnov 2025-02-17 17:57:41 +02:00
parent ecb9919e02
commit 8b1bb40baa
No known key found for this signature in database
6 changed files with 103 additions and 6 deletions

View file

@ -0,0 +1,27 @@
local t = require "spec.testutils"
local child = MiniTest.new_child_neovim()
local T = MiniTest.new_set {
hooks = {
post_once = child.stop,
pre_case = function()
child.restart { "-u", "scripts/minimal_init.lua" }
end,
},
}
T["iferr"] = MiniTest.new_set {}
T["iferr"]["works"] = function()
local tmp = vim.env.HOME .. "/test.go"
local fixtures = t.fixtures.read "iferr/iferr"
t.fixtures.write(tmp, fixtures.input)
child.cmd("silent edit " .. tmp)
child.fn.setpos(".", { child.fn.bufnr "%", 8, 2, 0 })
child.cmd "GoIfErr"
child.cmd "write"
t.eq(t.readfile(tmp), fixtures.output)
end
return T

View file

@ -1,9 +1,27 @@
local t = require "spec.testutils"
local T = MiniTest.new_set {}
local child = MiniTest.new_child_neovim()
local T = MiniTest.new_set {
hooks = {
post_once = child.stop,
pre_case = function()
child.restart { "-u", "scripts/minimal_init.lua" }
end,
},
}
T["struct_tags"] = MiniTest.new_set {}
T["struct_tags"]["fuck it"] = function()
t.eq(1, 1)
T["struct_tags"][".add"] = function()
local tmp = vim.env.HOME .. "/test.go"
local fixtures = t.fixtures.read "tags/add"
t.fixtures.write(tmp, fixtures.input)
child.cmd("silent edit " .. tmp)
child.fn.setpos(".", { child.fn.bufnr "%", 3, 6, 0 })
child.cmd "GoTagAdd json"
child.cmd "write"
t.eq(t.readfile(tmp), fixtures.output)
end
return T