MCPcopy
hub / github.com/perkeep/perkeep / TestQueryBlobRefPrefix

Function TestQueryBlobRefPrefix

pkg/search/query_test.go:239–267  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

237}
238
239func TestQueryBlobRefPrefix(t *testing.T) {
240 testQuery(t, func(qt *queryTest) {
241 id := qt.id
242
243 // foo is sha224-0808f64e60d58979fcb676c96ec938270dea42445aeefcd3a4e6f8db
244 id.UploadFile("file.txt", "foo", time.Unix(1382073153, 0))
245 // bar is sha224-07daf010de7f7f0d8d76a76eb8d1eb40182c8d1e7a3877a6686c9bf0
246 id.UploadFile("file.txt", "bar", time.Unix(1382073153, 0))
247
248 sq := &SearchQuery{
249 Constraint: &Constraint{
250 BlobRefPrefix: "sha224-0",
251 },
252 }
253 sres, err := qt.Handler().Query(ctxbg, sq)
254 if err != nil {
255 t.Fatal(err)
256 }
257 if len(sres.Blobs) < 2 {
258 t.Errorf("expected at least 2 matches; got %d", len(sres.Blobs))
259 }
260 for _, res := range sres.Blobs {
261 brStr := res.Blob.String()
262 if !strings.HasPrefix(brStr, "sha224-0") {
263 t.Errorf("matched blob %s didn't begin with sha224-0", brStr)
264 }
265 }
266 })
267}
268
269func TestQueryTwoConstraints(t *testing.T) {
270 testQuery(t, func(qt *queryTest) {

Callers

nothing calls this directly

Calls 7

testQueryFunction · 0.85
HandlerMethod · 0.80
FatalMethod · 0.80
HasPrefixMethod · 0.80
QueryMethod · 0.65
UploadFileMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected