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.
This commit is contained in:
parent
53ab4274c2
commit
e90f766ea3
8 changed files with 40 additions and 38 deletions
|
|
@ -1,5 +1,5 @@
|
|||
local t = require "spec.testutils"
|
||||
local child, T = t.setup "gotests"
|
||||
local child, T, gotests = t.setup "gotests"
|
||||
|
||||
--- NOTE: :GoTestAdd is the only place that has actual logic
|
||||
--- All other parts are handled `gotests` itself.
|
||||
|
|
@ -10,7 +10,7 @@ local function read_testfile(fpath)
|
|||
return t.readfile(fpath:gsub(".go", "_test.go"))
|
||||
end
|
||||
|
||||
T["gotests"]["should add test for function under cursor"] = function()
|
||||
gotests["should add test for function under cursor"] = function()
|
||||
local rs = t.setup_test("tests/function", child, { 3, 5 })
|
||||
child.cmd "GoTestAdd"
|
||||
|
||||
|
|
@ -18,7 +18,7 @@ T["gotests"]["should add test for function under cursor"] = function()
|
|||
t.cleanup(rs)
|
||||
end
|
||||
|
||||
T["gotests"]["should add test for method under cursor"] = function()
|
||||
gotests["should add test for method under cursor"] = function()
|
||||
local rs = t.setup_test("tests/method", child, { 5, 19 })
|
||||
child.cmd "GoTestAdd"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue