(req *SearchQuery, wanted ...blob.Ref)
| 147 | } |
| 148 | |
| 149 | func (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 | |
| 182 | func TestQuery(t *testing.T) { |
| 183 | testQuery(t, func(qt *queryTest) { |
no test coverage detected