MCPcopy Create free account
hub / github.com/golang/appengine / TestSavingStruct

Function TestSavingStruct

search/struct_test.go:133–213  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

131}
132
133func TestSavingStruct(t *testing.T) {
134 testCases := []struct {
135 desc string
136 doc interface{}
137 wantFields []Field
138 wantFacets []Facet
139 }{
140 {
141 desc: "Basic struct",
142 doc: &struct {
143 Name string
144 Legs float64
145 }{"Gopher", 4},
146 wantFields: []Field{
147 {Name: "Name", Value: "Gopher"},
148 {Name: "Legs", Value: float64(4)},
149 },
150 },
151 {
152 desc: "Struct with tags",
153 doc: &struct {
154 Name string
155 Info string `search:"about"`
156 Legs float64 `search:",facet"`
157 Fuzz Atom `search:"Fur,facet"`
158 }{"Gopher", "Likes slide rules.", 4, Atom("furry")},
159 wantFields: []Field{
160 {Name: "Name", Value: "Gopher"},
161 {Name: "about", Value: "Likes slide rules."},
162 },
163 wantFacets: []Facet{
164 {Name: "Legs", Value: float64(4)},
165 {Name: "Fur", Value: Atom("furry")},
166 },
167 },
168 {
169 desc: "Ignore unexported struct fields",
170 doc: &struct {
171 Name string
172 info string
173 Legs float64 `search:",facet"`
174 fuzz Atom `search:",facet"`
175 }{"Gopher", "Likes slide rules.", 4, Atom("furry")},
176 wantFields: []Field{
177 {Name: "Name", Value: "Gopher"},
178 },
179 wantFacets: []Facet{
180 {Name: "Legs", Value: float64(4)},
181 },
182 },
183 {
184 desc: "Ignore fields marked -",
185 doc: &struct {
186 Name string
187 Info string `search:"-"`
188 Legs float64 `search:",facet"`
189 Fuzz Atom `search:"-,facet"`
190 }{"Gopher", "Likes slide rules.", 4, Atom("furry")},

Callers

nothing calls this directly

Calls 2

AtomTypeAlias · 0.70
saveStructWithMetaFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…