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)
| 1083 | // TODO: make all the indextest/tests.go |
| 1084 | // also test the three memory build modes that testQuery does. |
| 1085 | func 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 | |
| 1117 | func TestQueryFileCandidateSource(t *testing.T) { |
| 1118 | testQueryTypes(t, memIndexTypes, func(qt *queryTest) { |