MCPcopy
hub / github.com/perkeep/perkeep / wantRes

Method wantRes

pkg/search/query_test.go:149–180  ·  view source on GitHub ↗
(req *SearchQuery, wanted ...blob.Ref)

Source from the content-addressed store, hash-verified

147}
148
149func (qt *queryTest) wantRes(req *SearchQuery, wanted ...blob.Ref) {
150 if qt.itype == indexClassic {
151 req.Sort = Unsorted
152 }
153 if qt.candidateSource != "" {
154 ExportSetCandidateSourceHook(func(pickedCandidate string) {
155 if pickedCandidate != qt.candidateSource {
156 qt.t.Fatalf("unexpected candidateSource: got %v, want %v", pickedCandidate, qt.candidateSource)
157 }
158 })
159 }
160 res, err := qt.Handler().Query(ctxbg, req)
161 if err != nil {
162 qt.t.Fatal(err)
163 }
164 qt.res = res
165
166 need := make(map[blob.Ref]bool)
167 for _, br := range wanted {
168 need[br] = true
169 }
170 for _, bi := range res.Blobs {
171 if !need[bi.Blob] {
172 qt.t.Errorf("unexpected search result: %v", bi.Blob)
173 } else {
174 delete(need, bi.Blob)
175 }
176 }
177 for br := range need {
178 qt.t.Errorf("missing from search result: %v", br)
179 }
180}
181
182func TestQuery(t *testing.T) {
183 testQuery(t, func(qt *queryTest) {

Callers 15

TestQueryFunction · 0.80
TestQueryCamliTypeFunction · 0.80
TestQueryAnyCamliTypeFunction · 0.80
TestQueryBlobSizeFunction · 0.80
TestQueryTwoConstraintsFunction · 0.80
TestQueryLogicalOrFunction · 0.80
TestQueryLogicalAndFunction · 0.80
TestQueryLogicalXorFunction · 0.80
TestQueryLogicalNotFunction · 0.80

Calls 6

HandlerMethod · 0.95
deleteFunction · 0.85
FatalMethod · 0.80
FatalfMethod · 0.65
QueryMethod · 0.65

Tested by

no test coverage detected