(t testing.TB, fn func(*queryTest), itype indexType)
| 113 | } |
| 114 | |
| 115 | func 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 | |
| 149 | func (qt *queryTest) wantRes(req *SearchQuery, wanted ...blob.Ref) { |
| 150 | if qt.itype == indexClassic { |
no test coverage detected