feat(struct_tags): add :GoTagClear
This commit is contained in:
parent
10abcb661e
commit
07f86d669b
6 changed files with 50 additions and 5 deletions
11
spec/fixtures/tags/clear_input.go
vendored
Normal file
11
spec/fixtures/tags/clear_input.go
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
package main
|
||||
|
||||
type Test struct {
|
||||
ID int `json:"id" yaml:"id" xml:"id" db:"id"`
|
||||
Name string `json:"name" yaml:"name" xml:"name" db:"name"`
|
||||
Num int64 `json:"num" yaml:"num" xml:"num" db:"num"`
|
||||
Another struct {
|
||||
First int `json:"first" yaml:"first" xml:"first" db:"first"`
|
||||
Second string `json:"second" yaml:"second" xml:"second" db:"second"`
|
||||
} `json:"another" yaml:"another" xml:"another" db:"another"`
|
||||
}
|
||||
11
spec/fixtures/tags/clear_output.go
vendored
Normal file
11
spec/fixtures/tags/clear_output.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
|
||||
}
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@ local T = MiniTest.new_set {
|
|||
},
|
||||
}
|
||||
T["struct_tags"] = MiniTest.new_set {}
|
||||
T["struct_tags"]["works add"] = function()
|
||||
T["struct_tags"]["should add tag"] = function()
|
||||
local tmp = t.tmpfile()
|
||||
local fixtures = t.get_fixtures "tags/add"
|
||||
t.writefile(tmp, fixtures.input)
|
||||
|
|
@ -22,7 +22,7 @@ T["struct_tags"]["works add"] = function()
|
|||
t.eq(t.readfile(tmp), fixtures.output)
|
||||
end
|
||||
|
||||
T["struct_tags"]["works remove"] = function()
|
||||
T["struct_tags"]["should remove tag"] = function()
|
||||
local tmp = t.tmpfile()
|
||||
local fixtures = t.get_fixtures "tags/remove"
|
||||
t.writefile(tmp, fixtures.input)
|
||||
|
|
@ -34,7 +34,7 @@ T["struct_tags"]["works remove"] = function()
|
|||
t.eq(t.readfile(tmp), fixtures.output)
|
||||
end
|
||||
|
||||
T["struct_tags"]["works many structs"] = function()
|
||||
T["struct_tags"]["should be able to handle many structs"] = function()
|
||||
local tmp = t.tmpfile()
|
||||
local fixtures = t.get_fixtures "tags/many"
|
||||
t.writefile(tmp, fixtures.input)
|
||||
|
|
@ -46,4 +46,16 @@ T["struct_tags"]["works many structs"] = function()
|
|||
t.eq(t.readfile(tmp), fixtures.output)
|
||||
end
|
||||
|
||||
T["struct_tags"]["should clear struct"] = function()
|
||||
local tmp = t.tmpfile()
|
||||
local fixtures = t.get_fixtures "tags/clear"
|
||||
t.writefile(tmp, fixtures.input)
|
||||
|
||||
child.cmd("silent edit " .. tmp)
|
||||
child.fn.setpos(".", { child.fn.bufnr "%", 3, 1, 0 })
|
||||
child.cmd "GoTagClear"
|
||||
|
||||
t.eq(t.readfile(tmp), fixtures.output)
|
||||
end
|
||||
|
||||
return T
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue