gopher.nvim/spec/integration/iferr_test.lua
Smirnov Oleksandr 3dcf708d34
refactor: some refactoring of tests (#102)
* feat(tests): add utils that does most of tests boilerplate

* refactor(tests): rewrite using new thing

* refactor(tests): clean up everywhere

* refactor(tests): remove boilerplate even further

* refactor(tests): soon it will be too far

* refactor(tests): some test renaming
2025-03-22 21:19:59 +02:00

27 lines
648 B
Lua

local t = require "spec.testutils"
local child, T = t.setup "iferr"
T["iferr"]["should add if != nil {"] = function()
local rs = t.setup_test("iferr/iferr", child, { 8, 2 })
child.cmd "GoIfErr"
child.cmd "write"
t.eq(t.readfile(rs.tmp), rs.fixtures.output)
t.cleanup(rs)
end
T["iferr"]["should add if err with custom message"] = function()
child.lua [[
require("gopher").setup {
iferr = { message = 'fmt.Errorf("failed to %w", err)' }
} ]]
local rs = t.setup_test("iferr/message", child, { 6, 2 })
child.cmd "GoIfErr"
child.cmd "write"
t.eq(t.readfile(rs.tmp), rs.fixtures.output)
t.cleanup(rs)
end
return T