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

@ -12,7 +12,32 @@ function testutils.eq(a, b)
return MiniTest.expect.equality(a, b)
end
-- TODO: continue with writing fixtures helpers
-- https://github.com/olexsmir/gopher.nvim/pull/71/files
---@return string
function testutils.tmpfile()
return vim.fn.tempname() .. ".go"
end
---@param path string
---@return string
function testutils.readfile(path)
return vim.fn.join(vim.fn.readfile(path), "\n")
end
testutils.fixtures = {}
---@param fixture string
---@return {input: string, output: string}
function testutils.fixtures.read(fixture)
return {
input = testutils.readfile(fixtures_dir .. fixture .. "_input.go"),
output = testutils.readfile(fixtures_dir .. fixture .. "_output.go"),
}
end
---@param fpath string
---@param fixture string
function testutils.fixtures.write(fpath, fixture)
vim.fn.writefile(vim.split(fixture, "\n"), fpath)
end
return testutils