Ai
1 Star 0 Fork 0

iotas/toolkit

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
code_gen_test.go 1.86 KB
一键复制 编辑 原始数据 按行查看 历史
xuthus 提交于 2021-12-15 11:25 +08:00 . fix
package proto_parser
import (
"fmt"
format "gitee.com/iotas/toolkit/proto_format"
"github.com/sirupsen/logrus"
"os"
"path"
"path/filepath"
"testing"
)
func TestCodeGen(t *testing.T) {
err := CodeGen(&CodeGenConfig{
PbFilePath: "./parser.proto",
OutputPath: ".",
GrpcOutputPath: "",
IncludePbFiles: nil,
OutputNeedFormat: false,
NoGetScopeFunc: false,
})
if err != nil {
panic(err)
}
}
func TestGormCodeGen(t *testing.T) {
err := CodeGen(&CodeGenConfig{
PbFilePath: "./parser.proto",
OutputPath: ".",
NoGetScopeFunc: false,
DbDriveType: "gdbc",
})
if err != nil {
logrus.Errorf("get err: %+v", err)
}
}
func TestAddApi(t *testing.T) {
err := AddAPI("./parser.proto", "TestService", "Find", "POST")
if err != nil {
panic(err)
}
}
func TestAddRPC(t *testing.T) {
err := AddRPC("router_group.proto", "MemberInfo", "Find")
if err != nil {
panic(err)
}
}
func TestOutputMD(t *testing.T) {
err := OutputMD("./parser.proto", "CSecRisk", "AutoCheck", []string{})
if err != nil {
panic(err)
}
}
func TestParseGoFile(t *testing.T) {
var ag = new(AstTree)
err := ag.parseGoFile("./freq_controller.go", "Freq", nil)
if err != nil {
panic(err)
}
//ag.checkAndGenerateRouteStruct()
}
func TestFsDir(t *testing.T) {
name := path.Base(path.Dir("./gen_to.go"))
fmt.Println(name)
if name == "." {
realPath, _ := os.Getwd()
fmt.Println(realPath)
fmt.Println(filepath.Base(realPath))
}
}
func TestFormat(t *testing.T) {
fmt.Println(format.Format("./model/parser.proto"))
}
func TestAddRoute(t *testing.T) {
err := AddRoute("./parser.proto", "TestService", "/api/test", "./internal/controller/test_controller.go")
if err != nil {
fmt.Println(err)
}
}
func TestAddSVC(t *testing.T) {
err := AddSvc("./parser.proto", "TestService", "./internal/services/test_service.go")
if err != nil {
fmt.Println(err)
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/iotas/toolkit.git
git@gitee.com:iotas/toolkit.git
iotas
toolkit
toolkit
6a2c4ec13c63

搜索帮助