refactor(tests): soon it will be too far

This commit is contained in:
Oleksandr Smirnov 2025-03-22 20:38:55 +02:00
parent 2ca302a7a5
commit 4bf2806537
No known key found for this signature in database
6 changed files with 8 additions and 13 deletions

View file

@ -1,6 +1,5 @@
local t = require "spec.testutils"
local child, T = t.setup()
local child, T = t.setup "comment"
local function do_the_test(fixture, pos)
local rs = t.setup_test("comment/" .. fixture, child, pos)
@ -11,7 +10,6 @@ local function do_the_test(fixture, pos)
t.cleanup(rs)
end
T["comment"] = MiniTest.new_set {}
T["comment"]["should add comment to package"] = function()
do_the_test("package", { 1, 1 })
end

View file

@ -1,7 +1,5 @@
local t = require "spec.testutils"
local child, T = t.setup()
T["gotests"] = MiniTest.new_set {}
local child, T = t.setup "gotests"
--- NOTE: :GoTestAdd is the only place that has actual logic
--- All other parts are handled `gotests` itself.

View file

@ -1,7 +1,6 @@
local t = require "spec.testutils"
local child, T = t.setup "iferr"
local child, T = t.setup()
T["iferr"] = MiniTest.new_set {}
T["iferr"]["works"] = function()
local rs = t.setup_test("iferr/iferr", child, { 8, 2 })
child.cmd "GoIfErr"

View file

@ -1,7 +1,6 @@
local t = require "spec.testutils"
local child, T = t.setup "impl"
local child, T = t.setup()
T["impl"] = MiniTest.new_set {}
T["impl"]["works w io.Writer"] = function()
local rs = t.setup_test("impl/writer", child, { 3, 0 })
child.cmd "GoImpl w io.Writer"

View file

@ -1,7 +1,6 @@
local t = require "spec.testutils"
local child, T = t.setup "struct_tags"
local child, T = t.setup()
T["struct_tags"] = MiniTest.new_set {}
T["struct_tags"]["should add tag"] = function()
local rs = t.setup_test("tags/add", child, { 3, 6 })
child.cmd "GoTagAdd json"

View file

@ -6,8 +6,9 @@ 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()
function testutils.setup(name)
local child = MiniTest.new_child_neovim()
local T = MiniTest.new_set {
hooks = {
@ -18,6 +19,7 @@ function testutils.setup()
},
}
T[name] = MiniTest.new_set {}
return child, T
end