MCPcopy Index your code
hub / github.com/perkeep/perkeep / TestDecodeFileInfo

Function TestDecodeFileInfo

pkg/search/query_test.go:1085–1115  ·  view source on GitHub ↗

This really belongs in pkg/index for the index-vs-corpus tests, but it's easier here for now. TODO: make all the indextest/tests.go also test the three memory build modes that testQuery does.

(t *testing.T)

Source from the content-addressed store, hash-verified

1083// TODO: make all the indextest/tests.go
1084// also test the three memory build modes that testQuery does.
1085func TestDecodeFileInfo(t *testing.T) {
1086 ctx := context.Background()
1087 testQuery(t, func(qt *queryTest) {
1088 id := qt.id
1089 fileRef, wholeRef := id.UploadFile("file.gif", "GIF87afoo", time.Unix(456, 0))
1090 res, err := qt.Handler().Describe(ctx, &DescribeRequest{
1091 BlobRef: fileRef,
1092 })
1093 if err != nil {
1094 qt.t.Error(err)
1095 return
1096 }
1097 db := res.Meta[fileRef.String()]
1098 if db == nil {
1099 qt.t.Error("DescribedBlob missing")
1100 return
1101 }
1102 if db.File == nil {
1103 qt.t.Error("DescribedBlob.File is nil")
1104 return
1105 }
1106 if db.File.MIMEType != "image/gif" {
1107 qt.t.Errorf("DescribedBlob.File = %+v; mime type is not image/gif", db.File)
1108 return
1109 }
1110 if db.File.WholeRef != wholeRef {
1111 qt.t.Errorf("DescribedBlob.WholeRef: got %v, wanted %v", wholeRef, db.File.WholeRef)
1112 return
1113 }
1114 })
1115}
1116
1117func TestQueryFileCandidateSource(t *testing.T) {
1118 testQueryTypes(t, memIndexTypes, func(qt *queryTest) {

Callers

nothing calls this directly

Calls 6

testQueryFunction · 0.85
HandlerMethod · 0.80
DescribeMethod · 0.65
UploadFileMethod · 0.45
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected