mirror of
https://gitee.com/johng/gf
synced 2026-06-06 16:21:40 +08:00
cmd/gf: test gen ctrl comments (#3575)
This commit is contained in:
@ -307,3 +307,41 @@ func expectFilesContent(t *gtest.T, paths []string, expectPaths []string) {
|
||||
t.Assert(val, expect)
|
||||
}
|
||||
}
|
||||
|
||||
// https://github.com/gogf/gf/issues/3569
|
||||
func Test_Gen_Ctrl_Comments_Issue3569(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
var (
|
||||
ctrlPath = gfile.Temp(guid.S())
|
||||
apiFolder = gtest.DataPath("issue", "3569", "api")
|
||||
in = genctrl.CGenCtrlInput{
|
||||
SrcFolder: apiFolder,
|
||||
DstFolder: ctrlPath,
|
||||
WatchFile: "",
|
||||
SdkPath: "",
|
||||
SdkStdVersion: false,
|
||||
SdkNoV1: false,
|
||||
Clear: false,
|
||||
Merge: true,
|
||||
}
|
||||
)
|
||||
|
||||
err := gutil.FillStructWithDefault(&in)
|
||||
t.AssertNil(err)
|
||||
|
||||
err = gfile.Mkdir(ctrlPath)
|
||||
t.AssertNil(err)
|
||||
defer gfile.Remove(ctrlPath)
|
||||
|
||||
_, err = genctrl.CGenCtrl{}.Ctrl(ctx, in)
|
||||
t.AssertNil(err)
|
||||
|
||||
//apiInterface file
|
||||
var (
|
||||
genApi = apiFolder + filepath.FromSlash("/hello/hello.go")
|
||||
genApiExpect = apiFolder + filepath.FromSlash("/hello/hello_expect.go")
|
||||
)
|
||||
defer gfile.Remove(genApi)
|
||||
t.Assert(gfile.GetContents(genApi), gfile.GetContents(genApiExpect))
|
||||
})
|
||||
}
|
||||
|
||||
15
cmd/gf/internal/cmd/testdata/issue/3569/api/hello/hello_expect.go
vendored
Normal file
15
cmd/gf/internal/cmd/testdata/issue/3569/api/hello/hello_expect.go
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
// =================================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package hello
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/cmd/gf/v2/internal/cmd/testdata/issue/3569/api/hello/v1"
|
||||
)
|
||||
|
||||
type IHelloV1 interface {
|
||||
Hello(ctx context.Context, req *v1.HelloReq) (res *v1.HelloRes, err error)
|
||||
}
|
||||
24
cmd/gf/internal/cmd/testdata/issue/3569/api/hello/v1/req.go
vendored
Normal file
24
cmd/gf/internal/cmd/testdata/issue/3569/api/hello/v1/req.go
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
package v1
|
||||
|
||||
import "github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
type HelloReq struct {
|
||||
g.Meta `path:"/hello" tags:"Hello" method:"get" summary:"api-Hello"`
|
||||
}
|
||||
type HelloRes struct {
|
||||
g.Meta `mime:"text/html" example:"string"`
|
||||
}
|
||||
|
||||
// type Hello2Req struct {
|
||||
// g.Meta `path:"/hello2" tags:"Hello" method:"get" summary:"api-Hello2"`
|
||||
// }
|
||||
// type Hello2Res struct {
|
||||
// g.Meta `mime:"text/html" example:"string"`
|
||||
// }
|
||||
|
||||
//type Hello3Req struct {
|
||||
// g.Meta `path:"/hello3" tags:"Hello" method:"get" summary:"api-Hello3"`
|
||||
// PodState consts.PodPhase
|
||||
//}
|
||||
//type Hello3Res struct {
|
||||
//}
|
||||
Reference in New Issue
Block a user