MCPcopy
hub / github.com/perkeep/perkeep / testQueryType

Function testQueryType

pkg/search/query_test.go:115–147  ·  view source on GitHub ↗
(t testing.TB, fn func(*queryTest), itype indexType)

Source from the content-addressed store, hash-verified

113}
114
115func testQueryType(t testing.TB, fn func(*queryTest), itype indexType) {
116 defer index.SetVerboseCorpusLogging(true)
117 index.SetVerboseCorpusLogging(false)
118
119 idx := index.NewMemoryIndex() // string key-value pairs in memory, as if they were on disk
120 var err error
121 var corpus *index.Corpus
122 if itype == indexCorpusBuild {
123 if corpus, err = idx.KeepInMemory(); err != nil {
124 t.Fatal(err)
125 }
126 }
127 qt := &queryTest{
128 t: t,
129 id: indextest.NewIndexDeps(idx),
130 itype: itype,
131 }
132 qt.id.Fataler = t
133 qt.newHandler = func() *Handler {
134 h := NewHandler(idx, owner)
135 if itype == indexCorpusScan {
136 if corpus, err = idx.KeepInMemory(); err != nil {
137 t.Fatal(err)
138 }
139 idx.PreventStorageAccessForTesting()
140 }
141 if corpus != nil {
142 h.SetCorpus(corpus)
143 }
144 return h
145 }
146 fn(qt)
147}
148
149func (qt *queryTest) wantRes(req *SearchQuery, wanted ...blob.Ref) {
150 if qt.itype == indexClassic {

Callers 1

testQueryTypesFunction · 0.85

Calls 8

SetCorpusMethod · 0.95
SetVerboseCorpusLoggingFunction · 0.92
NewMemoryIndexFunction · 0.92
NewIndexDepsFunction · 0.92
KeepInMemoryMethod · 0.80
FatalMethod · 0.80
NewHandlerFunction · 0.70

Tested by

no test coverage detected