MCPcopy Create free account
hub / github.com/go-dev-frame/sponge / TestCrudInfo

Function TestCrudInfo

pkg/sql2code/parser/parser_test.go:601–661  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

599}
600
601func TestCrudInfo(t *testing.T) {
602 data := tmplData{
603 TableName: "User",
604 TName: "user",
605 NameFunc: false,
606 RawTableName: "user",
607 Fields: []tmplField{
608 {
609 ColName: "name",
610 Name: "Name",
611 GoType: "string",
612 Tag: "json:\"name\"",
613 Comment: "姓名",
614 JSONName: "name",
615 DBDriver: "mysql",
616 },
617 {
618 ColName: "age",
619 Name: "Age",
620 GoType: "int",
621 Tag: "json:\"age\"",
622 Comment: "年龄",
623 JSONName: "age",
624 DBDriver: "mysql",
625 },
626 {
627 ColName: "created_at",
628 Name: "CreatedAt",
629 GoType: "time.Time",
630 Tag: "json:\"created_at\"",
631 Comment: "创建时间",
632 JSONName: "createdAt",
633 DBDriver: "mysql",
634 },
635 },
636 Comment: "用户信息",
637 SubStructs: "",
638 ProtoSubStructs: "",
639 DBDriver: "mysql",
640 }
641
642 info := newCrudInfo(data)
643
644 isPrimary := info.isIDPrimaryKey()
645 assert.Equal(t, false, isPrimary)
646
647 code := info.getCode()
648 assert.Contains(t, code, `"tableNameCamel":"User","tableNameCamelFCL":"user"`)
649
650 grpcValidation := info.GetGRPCProtoValidation()
651 assert.Contains(t, grpcValidation, "validate.rules")
652
653 webValidation := info.GetWebProtoValidation()
654 assert.Contains(t, webValidation, "validate.rules")
655
656 info = nil
657 _ = info.isIDPrimaryKey()
658 _ = info.getCode()

Callers

nothing calls this directly

Calls 5

newCrudInfoFunction · 0.85
isIDPrimaryKeyMethod · 0.80
GetWebProtoValidationMethod · 0.80
getCodeMethod · 0.45

Tested by

no test coverage detected