feat(json2go): support manual input
This commit is contained in:
parent
72dd68f25f
commit
bc3ce2fdf4
4 changed files with 18 additions and 2 deletions
|
|
@ -72,8 +72,9 @@ end)
|
||||||
|
|
||||||
-- :GoJson
|
-- :GoJson
|
||||||
cmd("GoJson", function(opts)
|
cmd("GoJson", function(opts)
|
||||||
require("gopher.json2go").json2go(opts.fargs[1])
|
local inp = ((opts.args ~= "" and opts.args) or nil)
|
||||||
end, "?")
|
require("gopher.json2go").json2go(inp)
|
||||||
|
end, "*")
|
||||||
|
|
||||||
-- :GoTest
|
-- :GoTest
|
||||||
cmd("GoTestAdd", function()
|
cmd("GoTestAdd", function()
|
||||||
|
|
|
||||||
2
spec/fixtures/json2go/manual_input.go
vendored
Normal file
2
spec/fixtures/json2go/manual_input.go
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
package main
|
||||||
|
|
||||||
7
spec/fixtures/json2go/manual_output.go
vendored
Normal file
7
spec/fixtures/json2go/manual_output.go
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
type AutoGenerated struct {
|
||||||
|
User struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
} `json:"user"`
|
||||||
|
}
|
||||||
|
|
@ -14,6 +14,12 @@ json2go["should convert interativly"] = function()
|
||||||
end
|
end
|
||||||
|
|
||||||
json2go["should convert argument"] = function()
|
json2go["should convert argument"] = function()
|
||||||
|
local rs = t.setup_test("json2go/manual", child, { 2, 0 })
|
||||||
|
child.cmd [[GoJson {"user": {"name": "user-ovic"}}]]
|
||||||
|
child.cmd "write"
|
||||||
|
|
||||||
|
t.eq(t.readfile(rs.tmp), rs.fixtures.output)
|
||||||
|
t.cleanup(rs)
|
||||||
end
|
end
|
||||||
|
|
||||||
return T
|
return T
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue