()
| 309 | var handlerTests []handlerTest |
| 310 | |
| 311 | func initTests() []handlerTest { |
| 312 | return []handlerTest{ |
| 313 | { |
| 314 | name: "describe-missing", |
| 315 | setup: func(t *testing.T) indexAndOwner { |
| 316 | return indexAndOwner{ |
| 317 | index: index.NewMemoryIndex(), |
| 318 | owner: owner.BlobRef(), |
| 319 | } |
| 320 | }, |
| 321 | query: "describe?blobref=eabfakeref-0555", |
| 322 | want: parseJSON(`{ |
| 323 | "meta": { |
| 324 | } |
| 325 | }`), |
| 326 | }, |
| 327 | |
| 328 | { |
| 329 | name: "describe-jpeg-blob", |
| 330 | setup: func(t *testing.T) indexAndOwner { |
| 331 | idx := index.NewMemoryIndex() |
| 332 | tb, ok := testBlobs["blobcontents1"] |
| 333 | if !ok { |
| 334 | panic("blobcontents1 not found") |
| 335 | } |
| 336 | if _, err := idx.ReceiveBlob(ctxbg, tb.BlobRef(), tb.Reader()); err != nil { |
| 337 | panic(err) |
| 338 | } |
| 339 | return indexAndOwner{ |
| 340 | index: idx, |
| 341 | owner: owner.BlobRef(), |
| 342 | } |
| 343 | }, |
| 344 | query: "describe?blobref=" + tbRefStr("blobcontents1"), |
| 345 | want: parseJSON(`{ |
| 346 | "meta": { |
| 347 | "` + tbRefStr("blobcontents1") + `": { |
| 348 | "blobRef": "` + tbRefStr("blobcontents1") + `", |
| 349 | "size": ` + tbSize("blobcontents1") + ` |
| 350 | } |
| 351 | } |
| 352 | }`), |
| 353 | }, |
| 354 | |
| 355 | { |
| 356 | name: "describe-permanode", |
| 357 | setup: handlerDescribeTestSetup, |
| 358 | query: "describe", |
| 359 | postBody: `{ |
| 360 | "blobref": "` + tbRefStr("perma-123") + `", |
| 361 | "rules": [ |
| 362 | {"attrs": ["camliContent"]} |
| 363 | ] |
| 364 | }`, |
| 365 | want: parseJSON(`{ |
| 366 | "meta": { |
| 367 | "` + tbRefStr("fakeref-232") + `": { |
| 368 | "blobRef": "` + tbRefStr("fakeref-232") + `", |
no test coverage detected