mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-05-08 15:39:59 +08:00
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: kevwan <1918356+kevwan@users.noreply.github.com>
35 lines
904 B
Go
35 lines
904 B
Go
package gogen
|
|
|
|
import (
|
|
_ "embed"
|
|
|
|
"github.com/zeromicro/go-zero/tools/goctl/api/spec"
|
|
"github.com/zeromicro/go-zero/tools/goctl/config"
|
|
"github.com/zeromicro/go-zero/tools/goctl/internal/version"
|
|
"github.com/zeromicro/go-zero/tools/goctl/util/format"
|
|
)
|
|
|
|
//go:embed svc_test.tpl
|
|
var svcTestTemplate string
|
|
|
|
func genServiceContextTest(dir, rootPkg, projectPkg string, cfg *config.Config, api *spec.ApiSpec) error {
|
|
filename, err := format.FileNamingFormat(cfg.NamingFormat, contextFilename)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return genFile(fileGenConfig{
|
|
dir: dir,
|
|
subdir: contextDir,
|
|
filename: filename + "_test.go",
|
|
templateName: "svcTestTemplate",
|
|
category: category,
|
|
templateFile: svcTestTemplateFile,
|
|
builtinTemplate: svcTestTemplate,
|
|
data: map[string]any{
|
|
"projectPkg": projectPkg,
|
|
"version": version.BuildVersion,
|
|
},
|
|
})
|
|
}
|