Skip to content

Commit

Permalink
test(struct_tags): add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
olexsmir committed Aug 14, 2024
1 parent 30a26bc commit 9a4417a
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/integrational/test_struct_tags.lua
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9a4417a

Please # to comment.