(t *testing.T)
| 599 | } |
| 600 | |
| 601 | func 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() |
nothing calls this directly
no test coverage detected