sync develop with main (#119)
* chore: remove unused rules from nvim selene setup * test: add test for config * chore: update tasks, run tests on all recent versions * refactor(test): make helper test function more ergonomic In my opinion, requiring user to access tests via `T["module_name"]` was too fragile and typos prone. * fix(config): typo annotations * chore(ci): install go bins via gopher.nvim itself * feat(struct_tags): add range support (#117) * feat(struct_tags): add range support * refactor: use `start`, and `end_` naming for ranges * fix(testutils): validate provided cursor position * chore: update CONTRIBUTING.md * chore: add demos (#118) * chore: add dataset for demos * chore(demos): add demos * chore: update CONTRIBUTING * this copefully will fix comments gif * chore: add note about lazy loading * chore(readme): at this point there is no code from go.nvim or iferr * chore(readme): update the structure * chore(readme): change wording of some things
This commit is contained in:
parent
de585144eb
commit
76e817b5e1
37 changed files with 472 additions and 188 deletions
|
|
@ -6,9 +6,11 @@ local testutils = {}
|
|||
testutils.mininit_path = vim.fs.joinpath(base_dir, "scripts", "minimal_init.lua")
|
||||
testutils.fixtures_dir = vim.fs.joinpath(base_dir, "spec/fixtures")
|
||||
|
||||
---@param name string
|
||||
---@return MiniTest.child, table
|
||||
function testutils.setup(name)
|
||||
---@param mod string Module name for which to create a nested test set.
|
||||
---@return MiniTest.child child nvim client.
|
||||
---@return table T root test set created by `MiniTest.new_set()`.
|
||||
---@return table mod_name nested set of tests in `T[mod]`.
|
||||
function testutils.setup(mod)
|
||||
local child = MiniTest.new_child_neovim()
|
||||
local T = MiniTest.new_set {
|
||||
hooks = {
|
||||
|
|
@ -19,8 +21,8 @@ function testutils.setup(name)
|
|||
},
|
||||
}
|
||||
|
||||
T[name] = MiniTest.new_set {}
|
||||
return child, T
|
||||
T[mod] = MiniTest.new_set {}
|
||||
return child, T, T[mod]
|
||||
end
|
||||
|
||||
---@generic T
|
||||
|
|
@ -76,6 +78,8 @@ end
|
|||
---@param pos? number[]
|
||||
---@return gopher.TestUtilsSetup
|
||||
function testutils.setup_test(fixture, child, pos)
|
||||
vim.validate("pos", pos, "table", true)
|
||||
|
||||
local tmp = testutils.tmpfile()
|
||||
local fixtures = testutils.get_fixtures(fixture)
|
||||
|
||||
|
|
@ -84,6 +88,8 @@ function testutils.setup_test(fixture, child, pos)
|
|||
|
||||
local bufnr = child.fn.bufnr(tmp)
|
||||
if pos then
|
||||
assert(#pos == 2, "invalid cursor position")
|
||||
|
||||
child.fn.setpos(".", { bufnr, unpack(pos) })
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue