MCPcopy Create free account
hub / github.com/RTradeLtd/Lens / TestEngine_Search

Function TestEngine_Search

engine/engine_test.go:115–257  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

113}
114
115func TestEngine_Search(t *testing.T) {
116 var testContent = `You are currently using an enterprise storage solution powered by
117 Temporal, an API built for the Interplanetary File System. This platform
118 showcases the outstanding features that decentralized storage technologies
119 can offer you.`
120 var testObj = models.ObjectV2{
121 Hash: "abcde",
122 MD: models.MetaDataV2{
123 DisplayName: "my test object!",
124 MimeType: "text",
125 Category: "amazing startup",
126 Tags: []string{"test", "object"},
127 },
128 }
129
130 // not testing indexing capabilities, so we can share an instance
131 var l = zaptest.NewLogger(t).Sugar()
132 e, err := New(l, Opts{
133 StorePath: filepath.Join("tmp", t.Name()),
134 Queue: queue.Options{
135 Rate: 500 * time.Millisecond,
136 BatchSize: 1,
137 }})
138 if err != nil {
139 t.Error("failed to create engine: " + err.Error())
140 return
141 }
142 go e.Run()
143
144 // store test object in engine
145 e.Index(Document{&testObj, testContent, true})
146 time.Sleep(time.Second)
147
148 type args struct {
149 q Query
150 }
151 tests := []struct {
152 name string
153 args args
154 wantDoc bool
155 }{
156 {"ok: find test obj with hash",
157 args{Query{
158 // Needs text - hashes are only provided as a filtering option
159 Text: "Interplanetary File System",
160 Hashes: []string{testObj.Hash},
161 }},
162 true},
163 {"fail: do NOT find test obj with wrong hash filter",
164 args{Query{
165 Text: "Interplanetary File System",
166 Hashes: []string{"not_my_hash"},
167 }},
168 false},
169 {"ok: find test obj with subtext",
170 args{Query{
171 Text: "Interplanetary File System",
172 }},

Callers

nothing calls this directly

Calls 5

NewFunction · 0.70
IndexMethod · 0.65
SearchMethod · 0.65
CloseMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected