test(struct_tags): test both possible inputs
This commit is contained in:
parent
db44842565
commit
0b62f3b419
3 changed files with 50 additions and 4 deletions
11
spec/fixtures/tags/add_many_input.go
vendored
Normal file
11
spec/fixtures/tags/add_many_input.go
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
package main
|
||||
|
||||
type Test struct {
|
||||
ID int
|
||||
Name string
|
||||
Num int64
|
||||
Another struct {
|
||||
First int
|
||||
Second string
|
||||
}
|
||||
}
|
||||
11
spec/fixtures/tags/add_many_output.go
vendored
Normal file
11
spec/fixtures/tags/add_many_output.go
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
package main
|
||||
|
||||
type Test struct {
|
||||
ID int `test4:"id" test5:"id" test1:"id" test2:"id"`
|
||||
Name string `test4:"name" test5:"name" test1:"name" test2:"name"`
|
||||
Num int64 `test4:"num" test5:"num" test1:"num" test2:"num"`
|
||||
Another struct {
|
||||
First int `test4:"first" test5:"first" test1:"first" test2:"first"`
|
||||
Second string `test4:"second" test5:"second" test1:"second" test2:"second"`
|
||||
} `test4:"another" test5:"another" test1:"another" test2:"another"`
|
||||
}
|
||||
|
|
@ -16,8 +16,9 @@ T["struct_tags"]["should add tag"] = function()
|
|||
t.writefile(tmp, fixtures.input)
|
||||
|
||||
child.cmd("silent edit " .. tmp)
|
||||
child.fn.setpos(".", { child.fn.bufnr "%", 3, 6, 0 })
|
||||
child.fn.setpos(".", { child.fn.bufnr(tmp), 3, 6, 0 })
|
||||
child.cmd "GoTagAdd json"
|
||||
child.cmd "write"
|
||||
|
||||
t.eq(t.readfile(tmp), fixtures.output)
|
||||
end
|
||||
|
|
@ -28,8 +29,9 @@ T["struct_tags"]["should remove tag"] = function()
|
|||
t.writefile(tmp, fixtures.input)
|
||||
|
||||
child.cmd("silent edit " .. tmp)
|
||||
child.fn.setpos(".", { child.fn.bufnr "%", 4, 6, 0 })
|
||||
child.fn.setpos(".", { child.fn.bufnr(tmp), 4, 6, 0 })
|
||||
child.cmd "GoTagRm json"
|
||||
child.cmd "write"
|
||||
|
||||
t.eq(t.readfile(tmp), fixtures.output)
|
||||
end
|
||||
|
|
@ -40,8 +42,9 @@ T["struct_tags"]["should be able to handle many structs"] = function()
|
|||
t.writefile(tmp, fixtures.input)
|
||||
|
||||
child.cmd("silent edit " .. tmp)
|
||||
child.fn.setpos(".", { child.fn.bufnr "%", 10, 3, 0 })
|
||||
child.fn.setpos(".", { child.fn.bufnr(tmp), 10, 3, 0 })
|
||||
child.cmd "GoTagAdd testing"
|
||||
child.cmd "write"
|
||||
|
||||
t.eq(t.readfile(tmp), fixtures.output)
|
||||
end
|
||||
|
|
@ -52,8 +55,29 @@ T["struct_tags"]["should clear struct"] = function()
|
|||
t.writefile(tmp, fixtures.input)
|
||||
|
||||
child.cmd("silent edit " .. tmp)
|
||||
child.fn.setpos(".", { child.fn.bufnr "%", 3, 1, 0 })
|
||||
child.fn.setpos(".", { child.fn.bufnr(tmp), 3, 1, 0 })
|
||||
child.cmd "GoTagClear"
|
||||
child.cmd "write"
|
||||
|
||||
t.eq(t.readfile(tmp), fixtures.output)
|
||||
end
|
||||
|
||||
T["struct_tags"]["should add more than one tag"] = function()
|
||||
local tmp = t.tmpfile()
|
||||
local fixtures = t.get_fixtures "tags/add_many"
|
||||
t.writefile(tmp, fixtures.input)
|
||||
|
||||
--- with comma, like gomodifytags
|
||||
child.cmd("silent edit " .. tmp)
|
||||
child.fn.setpos(".", { child.fn.bufnr(tmp), 3, 1 })
|
||||
child.cmd "GoTagAdd test4,test5"
|
||||
child.cmd "write"
|
||||
|
||||
-- without comma
|
||||
child.cmd("silent edit " .. tmp)
|
||||
child.fn.setpos(".", { child.fn.bufnr(tmp), 3, 1 })
|
||||
child.cmd "GoTagAdd test1 test2"
|
||||
child.cmd "write"
|
||||
|
||||
t.eq(t.readfile(tmp), fixtures.output)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue