MCPcopy
hub / github.com/perkeep/perkeep / handlerDescribeTestSetup

Function handlerDescribeTestSetup

pkg/search/handler_test.go:197–231  ·  view source on GitHub ↗

initial setup of perma123 lastModtime is at test.ClockOrigin + 8s (last claim on perma123) on return.

(t *testing.T)

Source from the content-addressed store, hash-verified

195// initial setup of perma123
196// lastModtime is at test.ClockOrigin + 8s (last claim on perma123) on return.
197func handlerDescribeTestSetup(t *testing.T) indexAndOwner {
198 idx := index.NewMemoryIndex()
199 tf := new(test.Fetcher)
200 idx.InitBlobSource(tf)
201 idx.KeyFetcher = tf
202 fi := &fetcherIndex{
203 tf: tf,
204 idx: idx,
205 }
206
207 checkErr(t, fi.addBlob(ownerRef))
208 perma123 := testBlobs["perma-123"]
209 fi.addBlob(perma123)
210 fakeref232 := testBlobs["fakeref-232"]
211 checkErr(t, fi.addBlob(fakeref232))
212
213 lastModtime = test.ClockOrigin
214 checkErr(t, fi.addClaim(schema.NewSetAttributeClaim(perma123.BlobRef(), "camliContent", fakeref232.BlobRef().String())))
215
216 // Test deleting all attributes
217 checkErr(t, fi.addClaim(schema.NewAddAttributeClaim(perma123.BlobRef(), "wont-be-present", "x")))
218 checkErr(t, fi.addClaim(schema.NewAddAttributeClaim(perma123.BlobRef(), "wont-be-present", "y")))
219 checkErr(t, fi.addClaim(schema.NewDelAttributeClaim(perma123.BlobRef(), "wont-be-present", "")))
220
221 // Test deleting a specific attribute.
222 checkErr(t, fi.addClaim(schema.NewAddAttributeClaim(perma123.BlobRef(), "only-delete-b", "a")))
223 checkErr(t, fi.addClaim(schema.NewAddAttributeClaim(perma123.BlobRef(), "only-delete-b", "b")))
224 checkErr(t, fi.addClaim(schema.NewAddAttributeClaim(perma123.BlobRef(), "only-delete-b", "c")))
225 checkErr(t, fi.addClaim(schema.NewDelAttributeClaim(perma123.BlobRef(), "only-delete-b", "b")))
226
227 return indexAndOwner{
228 index: idx,
229 owner: owner.BlobRef(),
230 }
231}
232
233// extends handlerDescribeTestSetup but adds a camliContentImage to pn.
234// lastModtime is at test.ClockOrigin + 9s on return.

Calls 10

addBlobMethod · 0.95
addClaimMethod · 0.95
NewMemoryIndexFunction · 0.92
NewSetAttributeClaimFunction · 0.92
NewAddAttributeClaimFunction · 0.92
NewDelAttributeClaimFunction · 0.92
checkErrFunction · 0.85
InitBlobSourceMethod · 0.80
BlobRefMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected