test(struct_tags): add tests
This commit is contained in:
parent
30a26bcda2
commit
9a4417a0aa
1 changed files with 40 additions and 0 deletions
40
tests/integrational/test_struct_tags.lua
Normal file
40
tests/integrational/test_struct_tags.lua
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
local u = require "gopher._utils.testutil"
|
||||||
|
local eq = MiniTest.expect.equality
|
||||||
|
|
||||||
|
local T = MiniTest.new_set()
|
||||||
|
T["struct_tags"] = MiniTest.new_set()
|
||||||
|
T["struct_tags"]['.add("json")'] = function()
|
||||||
|
local tmp = u.tmp_file()
|
||||||
|
local fixtures = u.read_fixture "tags/add"
|
||||||
|
u.write_fixture(tmp, fixtures.input)
|
||||||
|
|
||||||
|
vim.cmd("silent edit" .. tmp)
|
||||||
|
vim.bo.filetype = "go"
|
||||||
|
vim.fn.setpos(".", { vim.fn.bufnr "%", 3, 6, 0 })
|
||||||
|
|
||||||
|
require("gopher.struct_tags").add "json"
|
||||||
|
vim.wait(500)
|
||||||
|
|
||||||
|
eq(u.readfile(tmp), fixtures.output)
|
||||||
|
|
||||||
|
u.cleanup(tmp)
|
||||||
|
end
|
||||||
|
|
||||||
|
T["struct_tags"][".remove()"] = function()
|
||||||
|
local tmp = u.tmp_file()
|
||||||
|
local fixtures = u.read_fixture "tags/remove"
|
||||||
|
u.write_fixture(tmp, fixtures.input)
|
||||||
|
|
||||||
|
vim.cmd("silent edit" .. tmp)
|
||||||
|
vim.bo.filetype = "go"
|
||||||
|
vim.fn.setpos(".", { vim.fn.bufnr "%", 3, 6, 0 })
|
||||||
|
|
||||||
|
require("gopher.struct_tags").remove "json"
|
||||||
|
vim.wait(500)
|
||||||
|
|
||||||
|
eq(u.readfile(tmp), fixtures.output)
|
||||||
|
|
||||||
|
u.cleanup(tmp)
|
||||||
|
end
|
||||||
|
|
||||||
|
return T
|
||||||
Loading…
Add table
Add a link
Reference in a new issue