MCPcopy
hub / github.com/go-gorm/gorm / TestParseIndex

Function TestParseIndex

schema/index_test.go:58–172  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

56}
57
58func TestParseIndex(t *testing.T) {
59 user, err := schema.Parse(&UserIndex{}, &sync.Map{}, schema.NamingStrategy{})
60 if err != nil {
61 t.Fatalf("failed to parse user index, got error %v", err)
62 }
63
64 results := []*schema.Index{
65 {
66 Name: "idx_user_indices_name",
67 Fields: []schema.IndexOption{{Field: &schema.Field{Name: "Name"}}},
68 },
69 {
70 Name: "idx_name",
71 Class: "UNIQUE",
72 Fields: []schema.IndexOption{{Field: &schema.Field{Name: "Name2", UniqueIndex: "idx_name"}}},
73 },
74 {
75 Name: "idx_user_indices_name3",
76 Type: "btree",
77 Where: "name3 != 'jinzhu'",
78 Fields: []schema.IndexOption{{
79 Field: &schema.Field{Name: "Name3"},
80 Sort: "desc",
81 Collate: "utf8",
82 Length: 10,
83 }},
84 },
85 {
86 Name: "idx_user_indices_name4",
87 Class: "UNIQUE",
88 Fields: []schema.IndexOption{{Field: &schema.Field{Name: "Name4", UniqueIndex: "idx_user_indices_name4"}}},
89 },
90 {
91 Name: "idx_user_indices_name5",
92 Class: "FULLTEXT",
93 Comment: "hello , world",
94 Where: "age > 10",
95 Fields: []schema.IndexOption{{Field: &schema.Field{Name: "Name5"}}},
96 },
97 {
98 Name: "profile",
99 Comment: "hello , world",
100 Where: "age > 10",
101 Option: "WITH PARSER parser_name",
102 Fields: []schema.IndexOption{{Field: &schema.Field{Name: "Name6"}}, {
103 Field: &schema.Field{Name: "Age"},
104 Expression: "ABS(age)",
105 }},
106 },
107 {
108 Name: "idx_id",
109 Fields: []schema.IndexOption{{Field: &schema.Field{Name: "MemberNumber"}}, {Field: &schema.Field{Name: "OID", UniqueIndex: "idx_oid"}}},
110 },
111 {
112 Name: "idx_oid",
113 Class: "UNIQUE",
114 Fields: []schema.IndexOption{{Field: &schema.Field{Name: "OID", UniqueIndex: "idx_oid"}}},
115 },

Callers

nothing calls this directly

Calls 3

ParseFunction · 0.92
CheckIndicesFunction · 0.85
ParseIndexesMethod · 0.80

Tested by

no test coverage detected